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

Implement TransientMechanicalSimulation results #282

Merged
merged 33 commits into from
Feb 16, 2023

Conversation

PProfizi
Copy link
Contributor

@PProfizi PProfizi commented Feb 10, 2023

Implement result extraction APIs for TransientMechanicalSimulation.

TransientMechanicalSimulation methods

(checked: tested, italic: implemented)

  • displacement
  • velocity
  • acceleration
  • stress, stress_elemental, stress_nodal
  • stress_principal, stress_principal_nodal, stress_principal_elemental
  • stress_eqv_von_mises, stress_eqv_von_mises_elemental, stress_eqv_von_mises_nodal
  • elastic_strain, elastic_strain_nodal, elastic_strain_elemental
  • elastic_strain_principal, elastic_strain_principal_nodal, elastic_strain_principal_elemental
  • elastic_strain_energy_density
  • plastic_state_variable
  • plastic_strain, plastic_strain_nodal, plastic_strain_elemental
  • plastic_strain_principal, plastic_strain_principal_nodal, plastic_strain_principal_elemental
  • plastic_strain_eqv, plastic_strain_eqv_elemental, plastic_strain_eqv_nodal
  • plastic_strain_energy_density
  • plastic_strain_eqv_accu
  • reaction_forc
  • thermal_dissipation_energy? -> It is there, don't think it should be.
  • artificial_hourglass_energy? -> It is there, don't think it should be.
  • kinetic_energy? -> It is there, don't think it should be.
  • structural_temperature, structural_temperature_elemental, structural_temperature_nodal
  • element_nodal_forces, element_nodal_forces_nodal, element_nodal_forces_elemental
  • nodal_force
  • nodal_moment
  • thickness
  • element_centroids
  • element_orientations
  • elemental_heat_generation
  • elemental_mass
  • elemental_volume
  • total_mass?
  • hydrostatic pressure

I would like to merge the work already done, this being mostly about the logic behind result extraction.
I lack result files with most of the results types not tested above, so the work of being exhaustive is not prioritized right now.

@PProfizi PProfizi added the enhancement New feature or request label Feb 10, 2023
@PProfizi PProfizi self-assigned this Feb 10, 2023
@PProfizi PProfizi changed the base branch from master to post_refactor February 10, 2023 15:35
@PProfizi PProfizi closed this Feb 10, 2023
@PProfizi PProfizi reopened this Feb 10, 2023
"""Extract displacement results from the simulation.

Args:
component_ids:
Copy link
Contributor

Choose a reason for hiding this comment

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

@PProfizi the docstring for component ids is not very clear, could we have a list of supported options on each result type?

Whether to return the norm of the results.
selection:
Selection to get results for.
A Selection defines both spatial and time-like criteria for filtering.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that information about redundant keyopts is missing (for example times, time_steps_ids)
By the way, where do time_sets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a mention of priority order in each docstring.
As for time_sets, to me it is time_step_ids.

selection: Union[Selection, None] = None,
times: Union[float, List[float], None] = None,
time_step_ids: Union[int, List[int], None] = None,
nodes: Union[List[int], None] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we put time_step_ids, shouldn't we have node_ids instead of nodes for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching to node_ids and element_ids

time_step_ids: Union[int, List[int], None] = None,
nodes: Union[List[int], None] = None,
elements: Union[List[int], None] = None,
named_selection: Union[str, None] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we support a list of named selection? In the implementation, I can only see one named selection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was not part of the specs, but we can definitely add this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it!

named_selection=named_selection,
)

def plastic_state_variable_nodal(
Copy link
Contributor

Choose a reason for hiding this comment

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

what is plastic state? does it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The plastic state variable is ENL_PSV. I have not yet found a result containing that to add to the tests so right now I cannot say if this works.

named_selection=named_selection,
)

def hydrostatic_pressure_elemental(
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity which MAPDL result is hydrostatic_pressure ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It comes from NL HPRES.

@cbellot000 cbellot000 self-requested a review February 13, 2023 08:01
assert field.component_count == 3
assert np.allclose(field.data, field_ref.data)

def test_element_nodal_forces_elemental(self, allkindofcomplexity):
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that "named_selection" and "selection" keywords are not tested yet. is it because it's a work in progress?
Should we maybe add a code coverage bot to help?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just added a test for named_selection.
As for the Selection, the Selection object is not ready yet so no test for it. It is indeed a work in progress.

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Merging #282 (81dc806) into post_refactor (6eb8fc8) will increase coverage by 0.96%.
The diff coverage is 100.00%.

@@                Coverage Diff                @@
##           post_refactor     #282      +/-   ##
=================================================
+ Coverage          79.41%   80.38%   +0.96%     
=================================================
  Files                 30       32       +2     
  Lines               1963     2162     +199     
=================================================
+ Hits                1559     1738     +179     
- Misses               404      424      +20     

@PProfizi PProfizi force-pushed the post_refactor_transient_simulation branch from 16bf45b to 0faa1b0 Compare February 13, 2023 10:41
)

def test_displacement(self, static_simulation):
displacement_x = static_simulation.displacement(
component_ids=["X"], nodes=[42, 43, 44], set_ids=[1]
component_ids=["X"], node_ids=[42, 43, 44], set_ids=[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we should avoid using ids here. This can be confusing

result = transient_simulation.displacement(
components=["X"],
node_ids=[2, 3, 4],
all_sets=True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbellot000 is that what you had in mind? I added a boolean to ask explicitly for every set. This way it will be generic to all types of simulations, and it is very explicit.

@PProfizi PProfizi merged commit ab61458 into post_refactor Feb 16, 2023
@PProfizi PProfizi deleted the post_refactor_transient_simulation branch February 16, 2023 13:18
PProfizi added a commit that referenced this pull request Mar 8, 2023
* Use the time_scoping of the FieldsContainer and not its TimeFreqSupport

* Add TransientMechanicalSimulation.displacement

* Add TransientMechanicalSimulation.velocity and acceleration

* Add TransientMechanicalSimulation.stress and all variants

* Add TransientMechanicalSimulation.elastic_strain and all variants

* Move TransientMechanicalSimulation and StaticMechanicalSimulation to individual modules

* Confirm a first set of results for TransientMechanicalSimulation

* Specify available component IDs for vectorial results.

* Specify available component IDs for matrix results.

* Specify available component IDs for principal results. Rework all.

* Switching to node_ids and element_ids.

* Add the case of list of named selections

* Switch to node_ids in TestTransientMechanicalSimulation.

* Add testing for list of named_selections.

* Specify precedence of "selection" argument.

* Mention priority order for filtering arguments.

* Switch to node_ids, element_ids and named_selections in static_mechanical_simulation.py.

* Add component info for vector results in static_mechanical_simulation.py

* Add component info for matrix results in static_mechanical_simulation.py

* Add component info for principal results in static_mechanical_simulation.py

* Fix tests

* Fix DataObject docstring

* Fix 02-get_data_from_static_simulation.py

* component_ids -> components

* Also use set_ids, load_steps, and sub_steps, in signatures for transient_mechanical_simulation.py

* _build_mesh_scoping now returns either a Scoping or an operator Output giving a Scoping.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* Force mutual exclusivity of timefreq arguments, as well as of mesh scoping arguments

* Add an "all_sets" argument which is set to True means all sets will be extracted.

* Improve docstrings to explain extraction defaults in case of no argument given.

* Add implementation for "times" input.

* Reorder and fix all result methods signatures and docstrings.
PProfizi added a commit that referenced this pull request Mar 8, 2023
* Use the time_scoping of the FieldsContainer and not its TimeFreqSupport

* Add TransientMechanicalSimulation.displacement

* Add TransientMechanicalSimulation.velocity and acceleration

* Add TransientMechanicalSimulation.stress and all variants

* Add TransientMechanicalSimulation.elastic_strain and all variants

* Move TransientMechanicalSimulation and StaticMechanicalSimulation to individual modules

* Confirm a first set of results for TransientMechanicalSimulation

* Specify available component IDs for vectorial results.

* Specify available component IDs for matrix results.

* Specify available component IDs for principal results. Rework all.

* Switching to node_ids and element_ids.

* Add the case of list of named selections

* Switch to node_ids in TestTransientMechanicalSimulation.

* Add testing for list of named_selections.

* Specify precedence of "selection" argument.

* Mention priority order for filtering arguments.

* Switch to node_ids, element_ids and named_selections in static_mechanical_simulation.py.

* Add component info for vector results in static_mechanical_simulation.py

* Add component info for matrix results in static_mechanical_simulation.py

* Add component info for principal results in static_mechanical_simulation.py

* Fix tests

* Fix DataObject docstring

* Fix 02-get_data_from_static_simulation.py

* component_ids -> components

* Also use set_ids, load_steps, and sub_steps, in signatures for transient_mechanical_simulation.py

* _build_mesh_scoping now returns either a Scoping or an operator Output giving a Scoping.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* Force mutual exclusivity of timefreq arguments, as well as of mesh scoping arguments

* Add an "all_sets" argument which is set to True means all sets will be extracted.

* Improve docstrings to explain extraction defaults in case of no argument given.

* Add implementation for "times" input.

* Reorder and fix all result methods signatures and docstrings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants