Skip to content

Load Scenario File#46

Open
maksud wants to merge 14 commits intonicholson/scopflow-fix-rebasedfrom
maksud/load-scenarios
Open

Load Scenario File#46
maksud wants to merge 14 commits intonicholson/scopflow-fix-rebasedfrom
maksud/load-scenarios

Conversation

@maksud
Copy link
Copy Markdown
Collaborator

@maksud maksud commented Apr 23, 2026

Merge request type

  • New feature
  • Resolves bug
  • Documentation
  • Other

Relates to

  • OPFLOW
  • SOPFLOW
  • SCOPFLOW
  • TCOPFLOW
  • CMake build system
  • Spack configuration
  • Manual
  • Web docs
  • Other

This MR updates

  • Header files
  • Source code
  • CMake build system
  • Spack configuration
  • Web docs
  • Manual
  • Other

Summary

Added an implementation of incorporating P and Q load scenarios. Created a file format for the load scenarios in: datafiles/case9/10_scenarios_9bus_load.txt For each scenario in the file, it changes the load values of the bus list mentioned in the file.

The format of each scenario is like this:

1,0.101,8_Load_1_185.0_1000,6_Load_1_105.5_2000

1 = Scenario Number

0.101 = Weight

8_Load_1_185.0_1000,6_Load_1_105.5_2000 = list of load values

8_Load_1_185.0_1000 = Set Bus 8 with P = 185.0 and Q = 1000
6_Load_1_105.5_2000= Set Bus 6 with P = 105.0 and Q = 2000

@nkoukpaizan nkoukpaizan changed the base branch from develop to nicholson/testing-cmake-scopflow-fix April 23, 2026 18:05
@nkoukpaizan nkoukpaizan added enhancement New feature or request sopflow Related to stochastic optimal power flow analysis. labels Apr 23, 2026
@nkoukpaizan nkoukpaizan changed the base branch from nicholson/testing-cmake-scopflow-fix to develop April 23, 2026 18:18
Copy link
Copy Markdown
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest target branch is the one you branched off.

I also made a few comments with suggested improvements.

Comment on lines 12 to +13
char scenfile[PETSC_MAX_PATH_LEN];
char loadfile[PETSC_MAX_PATH_LEN];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are load files and scenario files different? Shouldn't there be single scenario file format including generation and load?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the loadfile variable name is not necessary actually. A single name is fine. I did not want to touch the variable name in the first implementation. I will drop the loadfile and use scenfile only.

Regarding Load and Generator together: It can be done but will require little bit more modification. The first cut focused on changing Load P and Q values. But I see I can use the same template to have different forecast types. Will try to submit the changes.

Comment on lines +1 to +4
scenario_nr,weight,kv_list
1,0.101,8_Load_1_185.0_1000,6_Load_1_105.5_2000
2,0.102,6_Load_1_105.0_10
3,0.103,8_Load_1_75.0_20
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat strange string format. Can't we use simple csv?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, the issue is similar to the argument for CSR type of file format.

For example, say we have a test case, where we want to add a large load to each bus and say we have 30k eligible buses. So we have 30k such scenarios.

In old format, we need to have 30k columns for each CSV file, and all will have original model values except 1 column for each scenario of the existing CSV format.

In this new format, we are just keeping the bus which need to be changes.

But I agree the format is a bit strange and I am open to suggestions for input format. We can rewrite the parser accordingly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we use JSON format?

@PhilipFackler, please chime in.

Comment on lines +21 to +22
PetscScalar *val1 = nullptr; /* forecast values */
PetscScalar *val2 = nullptr; /* 2nd set of forecast values */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are forecast values and "2nd set of forecast values"? This is somewhat counterintuitive.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current format, Forecast have a single value. But for a load, we want to change P and Q values simultaneously. So, either we can change the data type of val, or we can add add a second list of values. I used the second list here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to change P & Q simultaneously. They often change together but sometimes they don't as far as I know.

Comment thread include/common.h
Comment on lines 23 to +24
FORECAST_LOAD_P = 2,
FORECAST_LOAD_Q = 3
FORECAST_LOAD_PQ = 3
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is FORECAST_LOAD_Q changed into FORECAST_LOAD_PQ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to have the ability to change PQ value as a set. In later iterations, we can drop FORECAST_LOAD_P and use just FORECAST_GEN (after renaming FORECAST_WIND) and and FORECAST_LOAD.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why one would want to change P and Q as a set. They can and they occasionally do change separately.

@hambrickjc and @tsybinae: please chime in.

Comment on lines +3199 to 3200
ps->numits = opflow->numits;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why numits? Why not spell it out number_iterations?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my doing. opflow->numits was already defined, so I kept ps->numits. I agree we should rename both.

Comment on lines +86 to +91
// Body Example
// 1,0.1,8_Load_1_185.0_10,6_Load_1_105.5_20
while ((out = fgets(line, MAXLINE, fp)) != NULL) {
if (strcmp(line, "\r\n") == 0 || strcmp(line, "\n") == 0) {
continue; /* Skip blank lines */
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unintuitive way to define and parse input. Since we are creating new input file and matching parser, we don't need to use C string operations.

CC @PhilipFackler

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we can have a better parser to replace this code.

Comment on lines +110 to +113
vector<GenData> gendata;

tok = strtok(NULL, sep_comma);
sscanf(tok, "%lf", &weight);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think mixing STL and C standard library is not the best way to proceed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will replace the STL from here.

@maksud maksud changed the base branch from develop to nicholson/testing-cmake-scopflow-fix April 24, 2026 04:57
@maksud maksud changed the base branch from nicholson/testing-cmake-scopflow-fix to develop April 24, 2026 05:02
@maksud
Copy link
Copy Markdown
Collaborator Author

maksud commented Apr 24, 2026

I suggest target branch is the one you branched off.

I also made a few comments with suggested improvements.

I tried to change the target branch but it does not look great. Should I create another MR and close this one?

@nkoukpaizan
Copy link
Copy Markdown
Collaborator

I suggest target branch is the one you branched off.
I also made a few comments with suggested improvements.

I tried to change the target branch but it does not look great. Should I create another MR and close this one?

Yeah, this looks like a rebase to develop of nicholson/testing-cmake-scopflow-fix. Let me add a rebase of my branch and see if we can target that from here.

@nkoukpaizan nkoukpaizan changed the base branch from develop to nicholson/scopflow-fix-rebased April 24, 2026 18:15
@nkoukpaizan
Copy link
Copy Markdown
Collaborator

I suggest target branch is the one you branched off.
I also made a few comments with suggested improvements.

I tried to change the target branch but it does not look great. Should I create another MR and close this one?

Yeah, this looks like a rebase to develop of nicholson/testing-cmake-scopflow-fix. Let me add a rebase of my branch and see if we can target that from here.

@maksud You should now be able to rebase you branch on nicholson/scopflow-fix-rebased to isolate your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sopflow Related to stochastic optimal power flow analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants