Skip to content

Enabled timestepping->step size to be expression too #1166

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 2 commits into from
Jun 17, 2025
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
9 changes: 7 additions & 2 deletions flow360/component/simulation/framework/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _to_25_4_1(params_as_dict):
return params_as_dict


def _to_25_6_0(params_as_dict):
def _to_25_6_1(params_as_dict):
# Known: There can not be velocity_direction both under Inflow AND TotalPressure

# Move the velocity_direction under TotalPressure to the Inflow level.
Expand All @@ -197,6 +197,11 @@ def _to_25_6_0(params_as_dict):
):
params_as_dict["reference_geometry"]["area"]["type_name"] = "number"

# Add similar logic for step_size in time_stepping
if "time_stepping" in params_as_dict and "step_size" in params_as_dict["time_stepping"]:
if "type_name" not in params_as_dict["time_stepping"]["step_size"]:
params_as_dict["time_stepping"]["step_size"]["type_name"] = "number"

return params_as_dict


Expand All @@ -208,7 +213,7 @@ def _to_25_6_0(params_as_dict):
(Flow360Version("25.2.1"), _to_25_2_1),
(Flow360Version("25.2.3"), _to_25_2_3),
(Flow360Version("25.4.1"), _to_25_4_1),
(Flow360Version("25.6.0"), _to_25_6_0),
(Flow360Version("25.6.1"), _to_25_6_1),
] # A list of the Python API version tuple with there corresponding updaters.


Expand Down
5 changes: 4 additions & 1 deletion flow360/component/simulation/time_stepping/time_stepping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from flow360.component.simulation.framework.base_model import Flow360BaseModel
from flow360.component.simulation.unit_system import TimeType
from flow360.component.simulation.user_code.core.types import ValueOrExpression


def _apply_default_to_none(original, default):
Expand Down Expand Up @@ -174,7 +175,9 @@ class Unsteady(Flow360BaseModel):
)
steps: pd.PositiveInt = pd.Field(description="Number of physical steps.")
# pylint: disable=no-member
step_size: TimeType.Positive = pd.Field(description="Time step size in physical step marching,")
step_size: ValueOrExpression[TimeType.Positive] = pd.Field(
description="Time step size in physical step marching,"
)
# pylint: disable=duplicate-code
CFL: Union[RampCFL, AdaptiveCFL] = pd.Field(
default=AdaptiveCFL.default_unsteady(),
Expand Down
2 changes: 1 addition & 1 deletion flow360/component/v1/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _no_update(params_as_dict):
("25.2.3", "25.4.0", _no_update),
("25.4.0", "25.4.1", _no_update),
("25.4.1", "25.5.1", _no_update),
("25.5.1", "25.6.0", _no_update),
("25.5.1", "25.6.1", _no_update),
]


Expand Down
2 changes: 1 addition & 1 deletion flow360/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
version
"""

__version__ = "25.6.0b1"
__version__ = "25.6.1b1"
__solver_version__ = "release-25.6"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "flow360"
version = "v25.6.0b1"
version = "v25.6.1b1"
description = ""
authors = ["Flexcompute <support@flexcompute.com>"]

Expand Down
2 changes: 1 addition & 1 deletion tests/ref/simulation/service_init_geometry.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "25.6.0b1",
"version": "25.6.1b1",
"unit_system": {
"name": "SI"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/ref/simulation/service_init_surface_mesh.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "25.6.0b1",
"version": "25.6.1b1",
"unit_system": {
"name": "SI"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/ref/simulation/service_init_volume_mesh.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "25.6.0b1",
"version": "25.6.1b1",
"unit_system": {
"name": "SI"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/simulation/converter/ref/ref_monitor.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"25.6.0b1","unit_system":{"name":"SI"},"meshing":null,"reference_geometry":null,"operating_condition":null,"models":[{"material":{"type":"air","name":"air","dynamic_viscosity":{"reference_viscosity":{"value":0.00001716,"units":"Pa*s"},"reference_temperature":{"value":273.15,"units":"K"},"effective_temperature":{"value":110.4,"units":"K"}}},"initial_condition":{"type_name":"NavierStokesInitialCondition","constants":null,"rho":"rho","u":"u","v":"v","w":"w","p":"p"},"type":"Fluid","navier_stokes_solver":{"absolute_tolerance":1e-10,"relative_tolerance":0.0,"order_of_accuracy":2,"equation_evaluation_frequency":1,"linear_solver":{"max_iterations":30,"absolute_tolerance":null,"relative_tolerance":null},"private_attribute_dict":null,"CFL_multiplier":1.0,"kappa_MUSCL":-1.0,"numerical_dissipation_factor":1.0,"limit_velocity":false,"limit_pressure_density":false,"type_name":"Compressible","low_mach_preconditioner":false,"low_mach_preconditioner_threshold":null,"update_jacobian_frequency":4,"max_force_jac_update_physical_steps":0},"turbulence_model_solver":{"absolute_tolerance":1e-8,"relative_tolerance":0.0,"order_of_accuracy":2,"equation_evaluation_frequency":4,"linear_solver":{"max_iterations":20,"absolute_tolerance":null,"relative_tolerance":null},"private_attribute_dict":null,"CFL_multiplier":2.0,"type_name":"SpalartAllmaras","reconstruction_gradient_limiter":0.5,"quadratic_constitutive_relation":false,"modeling_constants":{"type_name":"SpalartAllmarasConsts","C_DES":0.72,"C_d":8.0,"C_cb1":0.1355,"C_cb2":0.622,"C_sigma":0.6666666666666666,"C_v1":7.1,"C_vonKarman":0.41,"C_w2":0.3,"C_t3":1.2,"C_t4":0.5,"C_min_rd":10.0},"update_jacobian_frequency":4,"max_force_jac_update_physical_steps":0,"hybrid_model":null,"rotation_correction":false, "controls":null},"transition_model_solver":{"type_name":"None"}}],"time_stepping":{"type_name":"Steady","max_steps":2000,"CFL":{"type":"adaptive","min":0.1,"max":10000.0,"max_relative_change":1.0,"convergence_limiting_factor":0.25}},"user_defined_dynamics":null,"user_defined_fields":[],"outputs":[{"name":"R1","entities":{"stored_entities":[{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"b9de2bce-36c1-4bbf-af0a-2c6a2ab713a4","name":"Point-0","location":{"value":[2.694298,0.0,1.0195910000000001],"units":"m"}}]},"output_fields":{"items":["primitiveVars"]},"output_type":"ProbeOutput"},{"name":"V3","entities":{"stored_entities":[{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"a79cffc0-31d0-499d-906c-f271c2320166","name":"Point-1","location":{"value":[4.007,0.0,-0.31760000000000005],"units":"m"}},{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"8947eb10-fc59-4102-b9c7-168a91ca22b9","name":"Point-2","location":{"value":[4.007,0.0,-0.29760000000000003],"units":"m"}},{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"27ac4e03-592b-4dba-8fa1-8f6678087a96","name":"Point-3","location":{"value":[4.007,0.0,-0.2776],"units":"m"}}]},"output_fields":{"items":["mut"]},"output_type":"ProbeOutput"}],"private_attribute_asset_cache":{"project_length_unit":null,"project_entity_info":null, "use_inhouse_mesher": false, "project_variables":null, "use_geometry_AI": false}}
{"version":"25.6.1b1","unit_system":{"name":"SI"},"meshing":null,"reference_geometry":null,"operating_condition":null,"models":[{"material":{"type":"air","name":"air","dynamic_viscosity":{"reference_viscosity":{"value":0.00001716,"units":"Pa*s"},"reference_temperature":{"value":273.15,"units":"K"},"effective_temperature":{"value":110.4,"units":"K"}}},"initial_condition":{"type_name":"NavierStokesInitialCondition","constants":null,"rho":"rho","u":"u","v":"v","w":"w","p":"p"},"type":"Fluid","navier_stokes_solver":{"absolute_tolerance":1e-10,"relative_tolerance":0.0,"order_of_accuracy":2,"equation_evaluation_frequency":1,"linear_solver":{"max_iterations":30,"absolute_tolerance":null,"relative_tolerance":null},"private_attribute_dict":null,"CFL_multiplier":1.0,"kappa_MUSCL":-1.0,"numerical_dissipation_factor":1.0,"limit_velocity":false,"limit_pressure_density":false,"type_name":"Compressible","low_mach_preconditioner":false,"low_mach_preconditioner_threshold":null,"update_jacobian_frequency":4,"max_force_jac_update_physical_steps":0},"turbulence_model_solver":{"absolute_tolerance":1e-8,"relative_tolerance":0.0,"order_of_accuracy":2,"equation_evaluation_frequency":4,"linear_solver":{"max_iterations":20,"absolute_tolerance":null,"relative_tolerance":null},"private_attribute_dict":null,"CFL_multiplier":2.0,"type_name":"SpalartAllmaras","reconstruction_gradient_limiter":0.5,"quadratic_constitutive_relation":false,"modeling_constants":{"type_name":"SpalartAllmarasConsts","C_DES":0.72,"C_d":8.0,"C_cb1":0.1355,"C_cb2":0.622,"C_sigma":0.6666666666666666,"C_v1":7.1,"C_vonKarman":0.41,"C_w2":0.3,"C_t3":1.2,"C_t4":0.5,"C_min_rd":10.0},"update_jacobian_frequency":4,"max_force_jac_update_physical_steps":0,"hybrid_model":null,"rotation_correction":false, "controls":null},"transition_model_solver":{"type_name":"None"}}],"time_stepping":{"type_name":"Steady","max_steps":2000,"CFL":{"type":"adaptive","min":0.1,"max":10000.0,"max_relative_change":1.0,"convergence_limiting_factor":0.25}},"user_defined_dynamics":null,"user_defined_fields":[],"outputs":[{"name":"R1","entities":{"stored_entities":[{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"b9de2bce-36c1-4bbf-af0a-2c6a2ab713a4","name":"Point-0","location":{"value":[2.694298,0.0,1.0195910000000001],"units":"m"}}]},"output_fields":{"items":["primitiveVars"]},"output_type":"ProbeOutput"},{"name":"V3","entities":{"stored_entities":[{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"a79cffc0-31d0-499d-906c-f271c2320166","name":"Point-1","location":{"value":[4.007,0.0,-0.31760000000000005],"units":"m"}},{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"8947eb10-fc59-4102-b9c7-168a91ca22b9","name":"Point-2","location":{"value":[4.007,0.0,-0.29760000000000003],"units":"m"}},{"private_attribute_registry_bucket_name":"PointEntityType","private_attribute_entity_type_name":"Point","private_attribute_id":"27ac4e03-592b-4dba-8fa1-8f6678087a96","name":"Point-3","location":{"value":[4.007,0.0,-0.2776],"units":"m"}}]},"output_fields":{"items":["mut"]},"output_type":"ProbeOutput"}],"private_attribute_asset_cache":{"project_length_unit":null,"project_entity_info":null, "use_inhouse_mesher": false, "project_variables":null, "use_geometry_AI": false}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "25.6.0b1",
"version": "25.6.1b1",
"unit_system": {
"name": "SI"
},
Expand Down
4 changes: 2 additions & 2 deletions tests/simulation/service/test_services_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def test_forward_compatibility_error():
)

assert errors[0] == {
"type": "99.99.99 > 25.6.0b1",
"type": "99.99.99 > 25.6.1b1",
"loc": [],
"msg": "The cloud `SimulationParam` is too new for your local Python client. "
"Errors may occur since forward compatibility is limited.",
Expand All @@ -1079,7 +1079,7 @@ def test_forward_compatibility_error():
)

assert errors[0] == {
"type": "99.99.99 > 25.6.0b1",
"type": "99.99.99 > 25.6.1b1",
"loc": [],
"msg": "[Internal] Your `SimulationParams` is too new for the solver. Errors may occur since forward compatibility is limited.",
"ctx": {},
Expand Down
14 changes: 7 additions & 7 deletions tests/simulation/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,14 @@ def test_updater_to_25_4_1():
assert params_new["meshing"]["defaults"]["geometry_accuracy"]["units"] == "m"


def test_updater_to_25_6_0():
def test_updater_to_25_6_1():
with open("../data/simulation/simulation_pre_25_6_0.json", "r") as fp:
params = json.load(fp)

def _update_to_25_6_0(pre_update_param_as_dict):
def _update_to_25_6_1(pre_update_param_as_dict):
params_new = updater(
version_from=f"25.5.1",
version_to=f"25.6.0",
version_to=f"25.6.1",
params_as_dict=pre_update_param_as_dict,
)
return params_new
Expand All @@ -508,29 +508,29 @@ def _ensure_validity(params):
assert params_new

pre_update_param_as_dict = copy.deepcopy(params)
params_new = _update_to_25_6_0(pre_update_param_as_dict)
params_new = _update_to_25_6_1(pre_update_param_as_dict)
assert params_new["models"][2]["velocity_direction"] == [0, -1, 0]
assert "velocity_direction" not in params_new["models"][2]["spec"]
_ensure_validity(params_new)

pre_update_param_as_dict = copy.deepcopy(params)
pre_update_param_as_dict["models"][2]["spec"]["velocity_direction"] = None
params_new = _update_to_25_6_0(pre_update_param_as_dict)
params_new = _update_to_25_6_1(pre_update_param_as_dict)
assert "velocity_direction" not in params_new["models"][2]
assert "velocity_direction" not in params_new["models"][2]["spec"]
_ensure_validity(params_new)

pre_update_param_as_dict = copy.deepcopy(params)
pre_update_param_as_dict["models"][2]["spec"].pop("velocity_direction")
params_new = _update_to_25_6_0(pre_update_param_as_dict)
params_new = _update_to_25_6_1(pre_update_param_as_dict)
assert "velocity_direction" not in params_new["models"][2]
assert "velocity_direction" not in params_new["models"][2]["spec"]
_ensure_validity(params_new)

pre_update_param_as_dict = copy.deepcopy(params)
pre_update_param_as_dict["models"][2]["spec"].pop("velocity_direction")
pre_update_param_as_dict["models"][2]["velocity_direction"] = [0, -1, 0]
params_new = _update_to_25_6_0(pre_update_param_as_dict)
params_new = _update_to_25_6_1(pre_update_param_as_dict)
assert params_new["models"][2]["velocity_direction"] == [0, -1, 0]
assert "velocity_direction" not in params_new["models"][2]["spec"]
_ensure_validity(params_new)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_current_flow360_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "25.6.0b1"
assert __version__ == "25.6.1b1"