Skip to content

[Tracking] Simulation Interface #253

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 135 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
4f102e9
added strucuture and interface for Simulation object (#239)
maciej-flexcompute May 1, 2024
1b64d6c
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 8, 2024
a3cacea
API for geometry (#257)
feilin-flexcompute May 14, 2024
43c8f26
Populate (almost) all model fields (#254)
benflexcompute May 15, 2024
57610b7
Fix PorousMedium example error noticed by YiFan
benflexcompute May 15, 2024
c930b2d
isort
benflexcompute May 15, 2024
7d05cda
add version to surface meshing params (#259)
feilin-flexcompute May 15, 2024
28dbe96
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 17, 2024
79865b6
Fix windows unit test failure because of accessing temp file before c…
benflexcompute May 17, 2024
90b7795
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 20, 2024
a88eaac
Merged volumes and surfaces into models to reflect latest design
benflexcompute May 21, 2024
cfb5ef2
Implement the framework for entities. (#258)
benflexcompute May 22, 2024
efefa03
[ModelRef] Added Field Definitions for **UserDefinedDynamics** (#271)
benflexcompute May 23, 2024
8e944f1
Fix the wrong way of checking exceptions (#276)
benflexcompute May 23, 2024
c56f91d
Allowing entityList to accept None so the using class can set None de…
benflexcompute May 24, 2024
616ae7e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 24, 2024
9928fa3
[ModelRef] Added Field Definitions for **Outputs** (#270)
benflexcompute May 28, 2024
e0736f9
support for pydantic v2 in unit system (#265)
maciej-flexcompute May 29, 2024
0204165
Disable Simulation Pylint for now as it is not even finished. (#283)
benflexcompute May 29, 2024
8d59a32
[ModelRef] Added Field Definitions for **TimeStepping** (#272)
benflexcompute May 29, 2024
d3d7a09
Fix bug where time average outputs are not listed (#284)
benflexcompute May 29, 2024
28b5df2
Added output format option (#285)
benflexcompute May 29, 2024
500443d
[ModelRef] Added Field Definitions for **ReferenceGeometry** (#280)
benflexcompute May 30, 2024
ec306bc
[ready for review] create surface mesh from geometry id (#262)
feilin-flexcompute May 30, 2024
183b436
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 30, 2024
83426f9
Add preprocess for base model (#281)
yifan-flex May 30, 2024
8e5bfe3
[ModelRef] Add Field Definitions for **OperatingCondition** (#275)
yifan-flex May 31, 2024
af9d86f
[ModelRef] Add Field Definitions for **SurfaceModels** (#274)
yifan-flex May 31, 2024
dce763f
[ModelRef] Added Field Definitions for **VolumeModels** (#273)
benflexcompute May 31, 2024
e6c379c
[ModelRef] Add Field Definitions for **MeshingParameters** (#279)
benflexcompute May 31, 2024
42fbf2d
Rename volume models: FluidDynamics->Fluid, HeatTransfer->Solid (#288)
yifan-flex May 31, 2024
2d8c1fa
Rename and separate FluidMaterialTypes and SolidMaterialTypes (#289)
yifan-flex May 31, 2024
e86fbd4
Add reference_mach to AerospaceCondition.from_mach (#286)
yifan-flex May 31, 2024
ffd8425
Deleted unused file (#291)
benflexcompute May 31, 2024
16a663a
remove box from enclosed_objects (#292)
benflexcompute May 31, 2024
8b275d6
Remove turbulent quantities from outflow (#293)
yifan-flex Jun 3, 2024
ffb3191
Fix some field definitions (#287)
benflexcompute Jun 3, 2024
422af43
Unify TranslationallyPeriodic and RotationallyPeriodic (#290)
yifan-flex Jun 3, 2024
c0b8701
Correct units for material default (#297)
yifan-flex Jun 3, 2024
f96fda1
Added seralizer for SimulationParam (#300)
benflexcompute Jun 6, 2024
a65a439
Add cache model serialization (#301)
yifan-flex Jun 6, 2024
a8ac05b
Added pylint back (#302)
benflexcompute Jun 6, 2024
adefa8e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 6, 2024
afd8e26
Created pydantic V2 version of the validation service, created tests.…
andrzej-krupka Jun 7, 2024
1df75cb
Unit conversion for simulationParam (#305)
benflexcompute Jun 7, 2024
31a6484
Renames and new meshing part (#306)
benflexcompute Jun 7, 2024
c723463
Added _type so translator knows the class (#307)
benflexcompute Jun 8, 2024
723bc36
Translator Utils (#310)
benflexcompute Jun 10, 2024
e7f927c
surface mesh translator (#309)
benflexcompute Jun 10, 2024
3fbc2b5
Revert " Added _type so translator knows the class (#307)"
yifan-flex Jun 10, 2024
843f512
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 10, 2024
a95b0d4
Ben y/volume meshing translator (#311)
benflexcompute Jun 11, 2024
efe80de
Add solver translator (#312)
yifan-flex Jun 11, 2024
15ecc90
Fixed all the unit test warnings (#315)
benflexcompute Jun 11, 2024
380832d
Enforce 0 warning (#316)
benflexcompute Jun 11, 2024
f1871bf
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 11, 2024
9630ced
Changed turbulent_viscosity_ratio to be positive only (#317)
benflexcompute Jun 11, 2024
60cf99c
Add service functions for translations. (#313)
benflexcompute Jun 12, 2024
6b3307e
Update cached model to store all constructor function arguments (#318)
yifan-flex Jun 12, 2024
7138f3d
construct from geometry to case (#321)
feilin-flexcompute Jun 12, 2024
9fe2bb5
Add BET solver JSON translator (#319)
benflexcompute Jun 17, 2024
2fec29e
fix volume params (#326)
feilin-flexcompute Jun 18, 2024
3fe8d8d
Entity Registry in SimulationParams (#328)
benflexcompute Jun 20, 2024
d8825a4
Remove _type attribute (#329)
yifan-flex Jun 20, 2024
4362cc7
Fix linting on python 3.9 (#331)
benflexcompute Jun 21, 2024
2feb4ca
Fix pylint for ALL simulation files. (#330)
benflexcompute Jun 21, 2024
18982eb
Add translator for rotation (#327)
yifan-flex Jun 21, 2024
80a5950
[ServiceIntegration] Add operating condition unit test for the implem…
benflexcompute Jun 24, 2024
a67e365
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 25, 2024
0a05038
Fix merge
benflexcompute Jun 25, 2024
14172f5
Fix model constants (#334)
yifan-flex Jun 25, 2024
49c1e01
Add from_axes for Box entities (#337)
yifan-flex Jun 26, 2024
f35d4aa
Maciej/workbench service (#335)
maciej-flexcompute Jun 28, 2024
7483b6a
minor fix on volume mesh JSON translator
maciej-flexcompute Jun 29, 2024
c24e328
translator: fixed farfield type format
maciej-flexcompute Jun 29, 2024
f98e89c
fixed translator tests
maciej-flexcompute Jun 29, 2024
0278781
added name to uniform refinement
maciej-flexcompute Jun 30, 2024
c41cbca
updated schemas
maciej-flexcompute Jun 30, 2024
a21dff7
fixed styling
maciej-flexcompute Jun 30, 2024
cc13213
added default axis and angle for box
maciej-flexcompute Jul 1, 2024
85c4a51
Prepend zone name to the surface name (#345)
benflexcompute Jul 1, 2024
4f8084c
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex Jul 1, 2024
c73d24b
output translator (#343)
benflexcompute Jul 1, 2024
eb64d1f
Removed hash from JSON when deserializing (#346)
benflexcompute Jul 2, 2024
1d0fd2e
Add tranlator for porous media (#339)
yifan-flex Jul 2, 2024
a148e4c
updated JSON examples for UI
maciej-flexcompute Jul 9, 2024
e8371b0
fixed black
maciej-flexcompute Jul 9, 2024
7e1ebf5
Fixed 500 Reponses (#353)
benflexcompute Jul 9, 2024
3ff1242
Merge remote-tracking branch 'origin/develop' into UnderConstruction/…
benflexcompute Jul 10, 2024
05a0f49
Add AutomatedFarfield (#347)
benflexcompute Jul 10, 2024
d9397c9
improved check on unit parser (#351)
maciej-flexcompute Jul 11, 2024
ae8a43b
added type discriminator to meshing->volume zones (#356)
maciej-flexcompute Jul 11, 2024
57575bf
Rebased (#352)
benflexcompute Jul 11, 2024
6f504a6
added default meshing to init service (#354)
maciej-flexcompute Jul 11, 2024
f633d8a
Added GhostSurface to full name detection and fixed the type name (#358)
benflexcompute Jul 12, 2024
a2301ef
added units to actuator disk (#357)
maciej-flexcompute Jul 12, 2024
6aadb50
Work around for inconsistent zone name from meshers (#360)
benflexcompute Jul 12, 2024
f87f418
fixed comparing to not None in if statements (#362)
maciej-flexcompute Jul 15, 2024
f8b125d
Remove reference geometry default from translator (#359)
yifan-flex Jul 15, 2024
2e06b21
Add actuator disk translator (#361)
yifan-flex Jul 15, 2024
f622440
Removed skipping defaults when getting a setting (#365)
benflexcompute Jul 16, 2024
119a789
Added validation of reusing cylinders in meshing (#363)
benflexcompute Jul 16, 2024
60b0813
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex Jul 16, 2024
81cf0bd
Fix unit tests
yifan-flex Jul 16, 2024
d6fe44a
Add CHT and periodic boundary translator (#348)
yifan-flex Jul 16, 2024
20ae144
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jul 17, 2024
90635d7
Fix front end JSON validation issues. (#368)
benflexcompute Jul 17, 2024
49acd72
Removed str from EntityList
benflexcompute Jul 17, 2024
1421474
added om6WingWallModel case
Jul 17, 2024
0dfcc81
isorted
Jul 17, 2024
f716b93
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jul 18, 2024
53d6d72
Minor changes to AD validation (#367)
yifan-flex Jul 18, 2024
8b36ef9
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jul 19, 2024
7b588c3
Updated Schema (#385)
benflexcompute Jul 22, 2024
6706e9f
Feilin/construction/surface mesh formats (#323)
feilin-flexcompute Jul 23, 2024
0136fa9
Make Slice and Probe entities (#390)
yifan-flex Jul 23, 2024
ab9864c
fix surface_mesh.py and upload examples for surface meshing (#389)
feilin-flexcompute Jul 24, 2024
6563b6f
Nasser/move cases (#387)
NasserFlexCompute Jul 24, 2024
63cdbd5
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex Jul 24, 2024
54489ed
Update unit test ref file hash
yifan-flex Jul 24, 2024
c11cb79
Added discriminator for timestepping (#394)
benflexcompute Jul 25, 2024
ae362f7
Add discriminator for some single attribute models (#393)
yifan-flex Jul 25, 2024
5e0f768
Rename Probe to ProbeGroup to avoid confusion (#396)
benflexcompute Jul 25, 2024
c193fc7
Just Update schema
benflexcompute Jul 26, 2024
8b24218
Fix missing value error in __init__ signature (#398)
benflexcompute Jul 26, 2024
58c1447
New geometry class (#397)
benflexcompute Jul 31, 2024
65ae8bb
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Aug 1, 2024
aeebe7d
Removed unused/unnecessary/outdated examples (#403)
benflexcompute Aug 1, 2024
c5b5133
Remove v2 examples as they are not simulation related
benflexcompute Aug 1, 2024
d334630
Mistakenly delete too many examples
benflexcompute Aug 1, 2024
b3a02b5
Update linting readme instruction and remove footpint of underconstru…
benflexcompute Aug 1, 2024
e2bee1e
Comments adddressed
benflexcompute Aug 1, 2024
b1c6d0c
Fix all sorts of small JIRA tickets (#401)
benflexcompute Aug 1, 2024
8068bfb
Added StandardAtmosphereModel implementation
benflexcompute Aug 2, 2024
6e0afbc
Fix Lint
benflexcompute Aug 2, 2024
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
2 changes: 0 additions & 2 deletions flow360/component/flow360_params/params_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
from ..types import COMMENTS, TYPE_TAG_STR
from .conversions import need_conversion, require, unit_converter

SUPPORTED_SOLVER_VERSION = "release-23.3.2.0"


def json_dumps(value, *args, **kwargs):
"""custom json dump with sort_keys=True"""
Expand Down
214 changes: 0 additions & 214 deletions flow360/component/geometry_v1.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to keep this 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.

It is not used anywhere except examples. Let's remove this.

This file was deleted.

2 changes: 1 addition & 1 deletion flow360/component/simulation/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def get_base_thermal_conductivity():
elif dimension == u.dimensions.angle:

# pylint: disable=no-member
flow360_conversion_unit_system.base_angle = 1 * u.rad
flow360_conversion_unit_system.base_angle = 1

elif dimension == u.dimensions.pressure:
base_force = get_base_force()
Expand Down
6 changes: 3 additions & 3 deletions flow360/component/simulation/framework/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from flow360.log import log


def custom_to_camel(string: str) -> str:
def snake_to_camel(string: str) -> str:
"""
Convert a snake_case string to camelCase.

Expand All @@ -40,7 +40,7 @@ def custom_to_camel(string: str) -> str:
str: The converted string in camelCase format.

Example:
>>> custom_to_camel("example_snake_case")
>>> snake_to_camel("example_snake_case")
'exampleSnakeCase'
"""
components = string.split("_")
Expand Down Expand Up @@ -116,7 +116,7 @@ def __pydantic_init_subclass__(cls, **kwargs) -> None:
include_hash=False,
include_defaults_in_schema=True,
alias_generator=pd.AliasGenerator(
serialization_alias=custom_to_camel,
serialization_alias=snake_to_camel,
),
)

Expand Down
13 changes: 7 additions & 6 deletions flow360/component/simulation/framework/entity_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@ def find_by_name(self, name: str):
raise ValueError(f"Multiple entities found in registry with given name: '{name}'.")
return entities[0]

def show(self):
def __str__(self):
"""
Prints a list of all registered entities, grouped by type.
Returns a string representation of all registered entities, grouped by type.
"""
index = 0
print("---- Content of the registry ----")
result = "---- Content of the registry ----\n"
# pylint: disable=no-member
for entity_bucket, entities in self.internal_registry.items():
print(f" Entities of type '{entity_bucket}':")
result += f" Entities of type '{entity_bucket}':\n"
for entity in entities:
print(f" - [{index:03d}]\n{entity}")
result += f" - [{index:03d}]\n{entity}\n"
index += 1
print("---- End of content ----")
result += "---- End of content ----"
return result

def clear(self):
"""
Expand Down
34 changes: 27 additions & 7 deletions flow360/component/simulation/operating_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,34 @@ def from_standard_atmosphere(
altitude: LengthType.Positive = 0 * u.m,
temperature_offset: TemperatureType = 0 * u.K,
):
"""Constructs a thermal state from the standard atmosphere model."""
# pylint: disable=fixme
# TODO: add standard atmosphere implementation
density = 1.225 * u.kg / u.m**3
temperature = 288.15 * u.K
"""Constructs a thermal state from the standard atmosphere model.

state = cls(density=density, temperature=temperature, material=Air())
Parameters:
altitude (LengthType.Positive): The altitude at which the state is calculated.
temperature_offset (TemperatureType): The offset to be applied to the standard temperature.

Returns:
ThermalState: The thermal state at the given altitude.
"""
# Standard atmosphere constants
t0 = 288.15 * u.K # Sea level standard temperature
p0 = 101325 * u.Pa # Sea level standard pressure
lapse_rate = 0.0065 * u.K / u.m # Temperature lapse rate
r = Air().gas_constant # Specific gas constant for dry air
g0 = 9.80665 * u.m / u.s**2 # Standard gravity

# Calculate temperature at the given altitude
temperature = t0 - lapse_rate * altitude
temperature += temperature_offset

# Calculate pressure at the given altitude
pressure = p0 * (1 - (lapse_rate * altitude / t0)) ** (g0 / (r * lapse_rate))

# Calculate density at the given altitude
density = pressure / (r * temperature)

# Construct and return the thermal state
state = cls(density=density, temperature=temperature, material=Air())
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure where this model comes from, but I think implementation of US standard atmosphere model is more complex, here is one implementation: https://github.com/flexcompute/design360/blob/develop/design360/client/utils/atmosphere_model.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied your implementation

return state

@property
Expand Down Expand Up @@ -113,7 +133,7 @@ def dynamic_viscosity(self) -> ViscosityType.Positive:

# TODO: should we make this private_attribute?
@pd.validate_call
def mu_ref(self, mesh_unit: LengthType.Positive) -> pd.PositiveFloat:
def _mu_ref(self, mesh_unit: LengthType.Positive) -> pd.PositiveFloat:
"""Computes nondimensional dynamic viscosity."""
# TODO: use unit system for nondimensionalization
return (self.dynamic_viscosity / (self.speed_of_sound * self.density * mesh_unit)).v.item()
Expand Down
3 changes: 1 addition & 2 deletions flow360/component/simulation/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ def _translate_simulation_json(

if translated_dict == {}:
raise ValueError(f"No {target_name} parameters found in given SimulationParams.")
# pylint: disable=fixme
# TODO: Implement proper hashing. Currently floating point creates headache for reproducible hashing.

# pylint: disable=protected-access
hash_value = SimulationParams._calculate_hash(translated_dict)
return translated_dict, hash_value
Expand Down
6 changes: 2 additions & 4 deletions flow360/component/simulation/simulation_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
from flow360.exceptions import Flow360ConfigurationError, Flow360RuntimeError
from flow360.version import __version__

AllowedModelTypes = Annotated[
Union[VolumeModelTypes, SurfaceModelTypes], pd.Field(discriminator="type")
]
ModelTypes = Annotated[Union[VolumeModelTypes, SurfaceModelTypes], pd.Field(discriminator="type")]


class _ParamModelBase(Flow360BaseModel):
Expand Down Expand Up @@ -165,7 +163,7 @@ class SimulationParams(_ParamModelBase):
3. by_name(pattern:str) to use regexpr/glob to select all zones/surfaces with matched name
3. by_type(pattern:str) to use regexpr/glob to select all zones/surfaces with matched type
"""
models: Optional[List[AllowedModelTypes]] = pd.Field(None)
models: Optional[List[ModelTypes]] = pd.Field(None)
"""
Below can be mostly reused with existing models
"""
Expand Down
3 changes: 2 additions & 1 deletion flow360/component/simulation/translator/solver_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ def get_solver_json(
if isinstance(op.thermal_state.material.dynamic_viscosity, Sutherland)
else -1
),
"muRef": op.thermal_state.mu_ref(mesh_unit),
# pylint: disable=protected-access
"muRef": op.thermal_state._mu_ref(mesh_unit),
}
if "reference_velocity_magnitude" in op.model_fields.keys() and op.reference_velocity_magnitude:
translated["freestream"]["MachRef"] = op.reference_velocity_magnitude.v.item()
Expand Down
8 changes: 8 additions & 0 deletions flow360/component/simulation/translator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,17 @@ def remove_units_in_dict(input_dict):
new_dict = {}
if input_dict.keys() == unit_keys:
new_dict = input_dict["value"]
if input_dict["units"].startswith("flow360_") is False:
raise ValueError(
f"[Internal Error] Unit {new_dict['units']} is not non-dimensionalized."
)
return new_dict
for key, value in input_dict.items():
if isinstance(value, dict) and value.keys() == unit_keys:
if value["units"].startswith("flow360_") is False:
raise ValueError(
f"[Internal Error] Unit {new_dict['units']} is not non-dimensionalized."
)
new_dict[key] = value["value"]
else:
new_dict[key] = remove_units_in_dict(value)
Expand Down
Loading
Loading