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

FEAT: Add transient support #4990

Merged
merged 4 commits into from
Aug 9, 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
Binary file added _unittest/example_models/T98/transient_fs.aedtz
Binary file not shown.
9 changes: 9 additions & 0 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
coldplate = "ColdPlateExample_231"
power_budget = "PB_test_231"
native_import = "one_native_component"
transient_fs = "transient_fs"

else:
coldplate = "ColdPlateExample"
Expand Down Expand Up @@ -1801,3 +1802,11 @@ def test_80_global_mesh_region(self):
g_m_r.update()
g_m_r.global_region.object.material_name = "Carbon Monoxide"
assert g_m_r.global_region.object.material_name == "Carbon Monoxide"

def test_81_transient_fs(self, add_app):
app = add_app(application=Icepak, project_name=transient_fs, subfolder=test_subfolder)
fs = app.post.create_field_summary()
for t in ["0s", "1s", "2s", "3s", "4s", "5s"]:
fs.add_calculation("Object", "Surface", "Box1", "Temperature", time=t)
df = fs.get_field_summary_data(pandas_output=True)
assert not df["Mean"].empty
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add also assert len(df) == 6 to ensure that all timesteps are added in the calculation. Also what will happen if the timestep provided is not in the solution timestep ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You'll get an error raised from AEDT. I didn't implement any sanity check (neither the possibility to add all time steps) as there is no way (from APIs) to get saved times. We could read this from setup props, but I don't think it's worth it. It can cause more problems than solutions.

36 changes: 20 additions & 16 deletions pyaedt/modules/AdvancedPostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,13 +1085,7 @@

@pyaedt_function_handler(faces_list="faces", quantity_name="quantity", design_variation="variation")
def evaluate_faces_quantity(
self,
faces,
quantity,
side="Default",
setup_name=None,
variations=None,
ref_temperature="",
self, faces, quantity, side="Default", setup_name=None, variations=None, ref_temperature="", time="0s"
):
"""Export the field surface output.

Expand All @@ -1111,6 +1105,8 @@
Dictionary of parameters defined for the specific setup with values. The default is ``{}``.
ref_temperature: str, optional
Reference temperature to use for heat transfer coefficient computation. The default is ``""``.
time : str
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
time : str
time : str, optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I should've added optional. I'll add that in another PR.

Timestep to get the data from. Default is ``"0s"``.

Returns
-------
Expand All @@ -1131,7 +1127,9 @@
facelist_name = generate_unique_name(quantity)
self._app.modeler.create_face_list(faces, facelist_name)
fs = self.create_field_summary()
fs.add_calculation("Object", "Surface", facelist_name, quantity, side=side, ref_temperature=ref_temperature)
fs.add_calculation(

Check warning on line 1130 in pyaedt/modules/AdvancedPostProcessing.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modules/AdvancedPostProcessing.py#L1130

Added line #L1130 was not covered by tests
"Object", "Surface", facelist_name, quantity, side=side, ref_temperature=ref_temperature, time=time
)
out = self._parse_field_summary_content(fs, setup_name, variations, quantity)
self._app.oeditor.Delete(["NAME:Selections", "Selections:=", facelist_name])
return out
Expand All @@ -1146,6 +1144,7 @@
setup_name=None,
variations=None,
ref_temperature="",
time="0s",
):
"""Export the field output on a boundary.

Expand All @@ -1169,6 +1168,8 @@
Dictionary of parameters defined for the specific setup with values. The default is ``{}``.
ref_temperature: str, optional
Reference temperature to use for heat transfer coefficient computation. The default is ``""``.
time : str
Timestep to get the data from. Default is ``"0s"``.

Returns
-------
Expand All @@ -1193,18 +1194,13 @@
quantity,
side=side,
ref_temperature=ref_temperature,
time=time,
)
return self._parse_field_summary_content(fs, setup_name, variations, quantity)

@pyaedt_function_handler(monitor_name="monitor", quantity_name="quantity", design_variation="variations")
def evaluate_monitor_quantity(
self,
monitor,
quantity,
side="Default",
setup_name=None,
variations=None,
ref_temperature="",
self, monitor, quantity, side="Default", setup_name=None, variations=None, ref_temperature="", time="0s"
):
"""Export monitor field output.

Expand All @@ -1224,6 +1220,8 @@
Dictionary of parameters defined for the specific setup with values. The default is ``{}``.
ref_temperature: str, optional
Reference temperature to use for heat transfer coefficient computation. The default is ``""``.
time : str
Timestep to get the data from. Default is ``"0s"``.

Returns
-------
Expand Down Expand Up @@ -1251,7 +1249,9 @@
else:
raise AttributeError("Monitor {} is not found in the design.".format(monitor))
fs = self.create_field_summary()
fs.add_calculation("Monitor", field_type, monitor, quantity, side=side, ref_temperature=ref_temperature)
fs.add_calculation(
"Monitor", field_type, monitor, quantity, side=side, ref_temperature=ref_temperature, time=time
)
return self._parse_field_summary_content(fs, setup_name, variations, quantity)

@pyaedt_function_handler(design_variation="variations")
Expand All @@ -1264,6 +1264,7 @@
setup_name=None,
variations=None,
ref_temperature="",
time="0s",
):
"""Export the field output on or in an object.

Expand All @@ -1285,6 +1286,8 @@
Dictionary of parameters defined for the specific setup with values. The default is ``{}``.
ref_temperature: str, optional
Reference temperature to use for heat transfer coefficient computation. The default is ``""``.
time : str
Timestep to get the data from. Default is ``"0s"``.

Returns
-------
Expand All @@ -1310,5 +1313,6 @@
quantity_name,
side=side,
ref_temperature=ref_temperature,
time=time,
)
return self._parse_field_summary_content(fs, setup_name, variations, quantity_name)
20 changes: 17 additions & 3 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5678,6 +5678,7 @@ def add_calculation(
side="Default",
mesh="All",
ref_temperature="AmbientTemp",
time="0s",
):
"""
Add an entry in the field summary calculation requests.
Expand Down Expand Up @@ -5710,6 +5711,8 @@ def add_calculation(
ref_temperature : str, optional
Reference temperature to use in the calculation of the heat transfer
coefficient. The default is ``"AmbientTemp"``.
time : str
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
time : str
time : str, optional

Timestep to get the data from. Default is ``"0s"``.

Returns
-------
Expand All @@ -5728,9 +5731,20 @@ def add_calculation(
normal = ",".join(normal)
if isinstance(geometry_name, str):
geometry_name = [geometry_name]
self.calculations.append(
[entity, geometry, ",".join(geometry_name), quantity, normal, side, mesh, ref_temperature, False]
) # TODO : last argument not documented
calc_args = [
entity,
geometry,
",".join(geometry_name),
quantity,
normal,
side,
mesh,
ref_temperature,
False,
] # TODO : last argument not documented
if self._app.solution_type == "Transient":
calc_args = [time] + calc_args
self.calculations.append(calc_args)
return True

@pyaedt_function_handler(IntrinsincDict="intrinsics", setup_name="setup", design_variation="variation")
Expand Down
Loading