-
Notifications
You must be signed in to change notification settings - Fork 56
Added new optiSLang integration test scenario #664
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1c419e3
Added new optiSLang integration test scenario
egravenh 8955a4c
Update tests/test_optislang/test_optislang_integration.py
egravenh 969c339
Update fixture_fluent.py
egravenh 18bae3d
Update tests/test_optislang/test_optislang_integration.py
egravenh 8351657
Update test_optislang_integration.py
egravenh f453ce2
Fixed style guide issues
egravenh c69044d
Merge branch 'main' into testing/optislang_integration
egravenh b83b387
Merge branch 'main' into testing/optislang_integration
egravenh 1ada5de
Merge branch 'main' into testing/optislang_integration
egravenh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| import ansys.fluent.core as pyfluent | ||
|
|
||
|
|
||
| @pytest.mark.optislang | ||
| @pytest.mark.integration | ||
| def test_simple_solve(load_mixing_elbow_param_case_dat): | ||
|
|
||
| """ | ||
| This optiSLang integration test performs these steps | ||
|
|
||
| - Reads a case file with and without data file | ||
| - Gets input and output parameters and creates dictionary | ||
| - Sets a variation on input parameters | ||
| - Solve | ||
| - Reread data | ||
|
|
||
| This test queries the following using PyTest: | ||
| - Input parameters | ||
| - Output parameters | ||
| """ | ||
|
|
||
| # Step 1: Setup logging | ||
| pyfluent.set_log_level("ERROR") | ||
|
|
||
| # Step 2: Launch fluent session and read case file with and without data file | ||
| session = load_mixing_elbow_param_case_dat | ||
| assert session.check_health() == "SERVING" | ||
| case_path = str(Path(pyfluent.EXAMPLES_PATH) / "elbow_param.cas.h5") | ||
| session.solver.tui.file.read_case_data(case_path) | ||
|
|
||
| # Step 3: Get input and output parameters and create a dictionary | ||
| from ansys.fluent.core.services.scheme_eval import Symbol | ||
|
|
||
| input_parameters = session.scheme_eval.eval((Symbol("list-input-parameters"),)) | ||
| output_parameters = session.scheme_eval.eval((Symbol("list-output-parameters"),)) | ||
| input_parameters = input_parameters["inlet2_temp"] | ||
| output_parameters = output_parameters["outlet_temp-op"] | ||
| session.solver.tui.file.read_case(case_path) | ||
|
|
||
| # Step 4: Set a variation on these input parameters | ||
| # variations/designs are generated by optiSLang based on | ||
| # algorithm selected | ||
| session.solver.tui.define.parameters.input_parameters.edit( | ||
| "inlet2_temp", "inlet2_temp", 600 | ||
| ) | ||
| session.solver.tui.file.write_case("design_elbow_param.cas.h5") | ||
|
|
||
| # Step 5: Solve | ||
| session.solver.tui.solve.initialize.initialize_flow() | ||
|
|
||
| # check if solution is steady or transient | ||
| workflow = session.scheme_eval.string_eval("(rp-unsteady?)") | ||
|
|
||
| # iterate workflow | ||
| if workflow == "#t": | ||
| session.solver.tui.solve.dual_time_iterate() | ||
| else: | ||
| session.solver.tui.solve.iterate() | ||
|
|
||
| convergence = session.scheme_eval.string_eval("(rpgetvar 'solution/converged?)") | ||
|
|
||
| # solution output (test conditional statement) | ||
| if convergence == "#f": # -> let user know | ||
| print("Failed to converge") | ||
| else: | ||
| print("Solution is converged") | ||
|
|
||
| assert convergence == "#t", "Solution failed to converge" | ||
|
|
||
| # Step 6: Read the data again from the case and data file | ||
| session.solver.tui.file.read_case_data(case_path) | ||
| input_parameters2 = session.scheme_eval.eval((Symbol("list-input-parameters"),)) | ||
| output_parameters2 = session.scheme_eval.eval((Symbol("list-output-parameters"),)) | ||
| input_parameters2 = input_parameters2["inlet2_temp"] | ||
| output_parameters2 = output_parameters2["outlet_temp-op"] | ||
|
|
||
| assert input_parameters[0] == input_parameters2[0] | ||
| assert output_parameters[0] == output_parameters2[0] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.