Skip to content

Andromede V1 model validation #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2025
Merged

Andromede V1 model validation #89

merged 5 commits into from
Apr 16, 2025

Conversation

aoustry
Copy link
Collaborator

@aoustry aoustry commented Apr 15, 2025

No description provided.

@aoustry aoustry requested a review from tbittar April 15, 2025 13:41
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need a time and scenario-dependent efficiency for the electrolyzer ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not for the moment, I changed this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe rename the file to test_andromede_v1_models to refer to the library name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

Choose a reason for hiding this comment

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

As all results file are in the results directory, you may remove _results from the file name for conciseness

#
# This file is part of the Antares project.

# Study Cluster Validation 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explain what you try to validate (that is different from validation_2 and validation_3) ?

Comment on lines 31 to 105
@pytest.mark.parametrize(
"system_file, optim_result_file, timespan, batch, relative_accuracy, results_dir, systems_dir, series_dir",
[
(
"dsr_validation.yml",
"dsr_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"base_validation.yml",
"base_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"electrolyser_validation.yml",
"electrolyser_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"storage_validation.yml",
"storage_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"bde_system.yml",
"bde_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"cluster_validation_1.yml",
"cluster_testing1_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"cluster_validation_2.yml",
"cluster_testing2_results.csv",
168,
20,
1e-4, # Default Fico XPRESS Tolerance
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
],
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.parametrize(
"system_file, optim_result_file, timespan, batch, relative_accuracy, results_dir, systems_dir, series_dir",
[
(
"dsr_validation.yml",
"dsr_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"base_validation.yml",
"base_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"electrolyser_validation.yml",
"electrolyser_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"storage_validation.yml",
"storage_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"bde_system.yml",
"bde_case_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"cluster_validation_1.yml",
"cluster_testing1_results.csv",
168,
20,
1e-6,
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
(
"cluster_validation_2.yml",
"cluster_testing2_results.csv",
168,
20,
1e-4, # Default Fico XPRESS Tolerance
"tests/e2e/models/results/",
"tests/e2e/models/systems/",
"tests/e2e/models/series/",
),
],
)
@pytest.fixture
def data_dir() -> Path:
return Path(__file__).parent
@pytest.fixture
def results_dir(data_dir: Path) -> Path:
return data_dir / "results"
@pytest.fixture
def systems_dir(data_dir: Path) -> Path:
return data_dir / "systems"
@pytest.fixture
def series_dir(data_dir: Path) -> Path:
return data_dir / "series"
@pytest.mark.parametrize(
"system_file, optim_result_file, timespan, batch, relative_accuracy",
[
(
"dsr_validation.yml",
"dsr_case_results.csv",
168,
20,
1e-6,
),
(
"base_validation.yml",
"base_case_results.csv",
168,
20,
1e-6,
),
(
"electrolyser_validation.yml",
"electrolyser_case_results.csv",
168,
20,
1e-6,
),
(
"storage_validation.yml",
"storage_case_results.csv",
168,
20,
1e-6,
),
(
"bde_system.yml",
"bde_case_results.csv",
168,
20,
1e-6,
),
(
"cluster_validation_1.yml",
"cluster_testing1_results.csv",
168,
20,
1e-6,
),
(
"cluster_validation_2.yml",
"cluster_testing2_results.csv",
168,
20,
1e-4, # Default Fico XPRESS Tolerance
),
],
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, thank you for the suggestion

) -> None:
scenarios = 1

with open(systems_dir + system_file) as compo_file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
with open(systems_dir + system_file) as compo_file:
with open(systems_dir / system_file) as compo_file:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

network = build_network(components_input)

reference_values = pd.read_csv(
results_dir + optim_result_file, header=None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
results_dir + optim_result_file, header=None
results_dir / optim_result_file, header=None

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 119 to 128
with open(
"src/andromede/libs/antares_historic/antares_historic.yml"
) as lib_file1:
with open(
"src/andromede/libs/reference_models/andromede_v1_models.yml"
) as lib_file2:
input_libraries = [
parse_yaml_library(lib_file1),
parse_yaml_library(lib_file2),
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
with open(
"src/andromede/libs/antares_historic/antares_historic.yml"
) as lib_file1:
with open(
"src/andromede/libs/reference_models/andromede_v1_models.yml"
) as lib_file2:
input_libraries = [
parse_yaml_library(lib_file1),
parse_yaml_library(lib_file2),
]
with open(
"src/andromede/libs/antares_historic/antares_historic.yml"
) as lib_file1:
lib_historic = parse_yaml_library(lib_file1)
with open(
"src/andromede/libs/reference_models/andromede_v1_models.yml"
) as lib_file2:
lib_v1 = parse_yaml_library(lib_file2)
input_libraries = [
parse_yaml_library(lib_file1),
parse_yaml_library(lib_file2),
]

You should put under the with only the code that needs to have the files open, as when we exit the with part the file is closed. In the current state, the two files stay open for the run

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@aoustry aoustry requested a review from tbittar April 16, 2025 11:54
) -> None:
scenarios = 1

with open(systems_dir / system_file) as compo_file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only put input_component = parse_yaml_components(compo_file) under this with

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 118 to 125
with open(
"src/andromede/libs/antares_historic/antares_historic.yml"
) as lib_file1:
lib_historic = parse_yaml_library(lib_file1)
with open(
"src/andromede/libs/reference_models/andromede_v1_models.yml"
) as lib_file2:
lib_v1 = parse_yaml_library(lib_file2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

As the libs are the same in all tests, I would make fixtures of them

@pytest.fixture
def lib_historic() -> InputLibrary:
    with open(
            "src/andromede/libs/antares_historic/antares_historic.yml"
        ) as lib_file1:
            lib_historic = parse_yaml_library(lib_file1)
    return lib_historic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@aoustry aoustry requested a review from tbittar April 16, 2025 15:40
@tbittar tbittar merged commit c91cd85 into main Apr 16, 2025
1 check passed
@tbittar tbittar deleted the models_validation_2 branch April 16, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants