Skip to content

Commit

Permalink
fix: Handle unitless parameters (#3427)
Browse files Browse the repository at this point in the history
* fix: Handle unitless parameters

* fix: Handle unitless parameters

* Update flobject.py

---------

Co-authored-by: Sean Pearson <[email protected]>
  • Loading branch information
mkundu1 and seanpearsonuk authored Oct 25, 2024
1 parent cb236c6 commit cb8cae3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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, ""],
}

0 comments on commit cb8cae3

Please sign in to comment.