Skip to content
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

fix: Handle unitless parameters #3427

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,13 +1750,13 @@ def __call__(self, *args, **kwds):
raise KeyboardInterrupt


# TODO: Remove this after paremater list() method is fixed from Fluent side
# TODO: Remove this after parameter list() method is fixed from Fluent side
def _fix_parameter_list_return(val):
if isinstance(val, dict):
new_val = {}
for name, v in val.items():
value, units = v
if len(units) > 0:
if len(units) > 0 and isinstance(units[0], str):
unit_labels = _fix_parameter_list_return.scheme_eval(
f"(units/inquire-available-label-strings-for-quantity '{units[0]})"
)
Expand Down
10 changes: 10 additions & 0 deletions tests/parametric/test_parametric_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ def test_parameters_list_function(static_mixer_settings_session):
create_output_param("report-definition", "outlet-temp-avg")
create_output_param("report-definition", "outlet-vel-avg")

# Create a unitless output parameter
unitless_quantity = solver.settings.solution.report_definitions.surface.create(
"temp-outlet-uniformity"
)
unitless_quantity.report_type = "surface-masswtui"
unitless_quantity.field = "temperature"
unitless_quantity.surface_names = ["outlet"]
unitless_quantity.output_parameter = True

input_parameters_list = solver.parameters.input_parameters.list()
output_parameters_list = solver.parameters.output_parameters.list()
assert input_parameters_list == {
Expand All @@ -266,4 +275,5 @@ def test_parameters_list_function(static_mixer_settings_session):
assert output_parameters_list == {
"outlet-temp-avg-op": [0.0, "K"],
"outlet-vel-avg-op": [0.0, "m/s"],
"temp-outlet-uniformity-op": [0.0, ""],
}