Skip to content

Small harmonic analysis improvements #1457

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 3 commits into from
Sep 7, 2022
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
75 changes: 42 additions & 33 deletions src/ansys/mapdl/core/_commands/solution/load_step_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@ def autots(self, key="", **kwargs):
key
Automatic time stepping key:

OFF - Do not use automatic time stepping.
OFF
Do not use automatic time stepping.

ON - Use automatic time stepping (default).
ON
Use automatic time stepping (default).

AUTO - The program determines whether to use automatic time stepping (used by
Workbench).
AUTO
The program determines whether to use automatic time stepping (used by
Workbench).

Notes
-----
Specifies whether to use automatic time stepping (or load stepping)
over this load step. If Key = ON, both time step prediction and time
step bisection will be used.

You cannot use automatic time stepping [AUTOTS], line search [LNSRCH],
You cannot use automatic time stepping ``AUTOTS``, line search ``LNSRCH``,
or the DOF solution predictor [PRED] with the arc-length method
[ARCLEN, ARCTRM]. If you activate the arc-length method after you set
AUTOTS, LNSRCH, or PRED, a warning message appears. If you choose to
``ARCLEN, ARCTRM``. If you activate the arc-length method after you set
``AUTOTS, LNSRCH``, or ``PRED``, a warning message appears. If you choose to
proceed with the arc-length method, the program disables your automatic
time stepping, line search, and DOF predictor settings, and the time
step size is controlled by the arc-length method internally.
Expand Down Expand Up @@ -53,9 +56,9 @@ def campbell(self, action="", **kwargs):

Notes
-----
For an analysis involving a prestressed structure, the CAMPBELL command
For an analysis involving a prestressed structure, the ``CAMPBELL`` command
specifies whether or not to prepare the result file to support a
Campbell diagram analysis (PRCAMP or PLCAMP).
Campbell diagram analysis (``PRCAMP`` or ``PLCAMP``).

To prestress a structure, the program performs a static solution before
the linear perturbation modal solution.
Expand Down Expand Up @@ -465,7 +468,7 @@ def nsubst(self, nsbstp="", nsbmx="", nsbmn="", carry="", **kwargs):
nsbstp
Number of substeps to be used for this load step (i.e., the time
step size or frequency increment). If automatic time stepping is
used (AUTOTS), NSBSTP defines the size of the first substep.
used (``AUTOTS``), ``NSBSTP`` defines the size of the first substep.

nsbmx
Maximum number of substeps to be taken (i.e., the minimum time step
Expand All @@ -481,18 +484,20 @@ def nsubst(self, nsbstp="", nsbmx="", nsbmn="", carry="", **kwargs):
Time step carryover key (program-determined default depending on
the problem physics):

OFF - Use NSBSTP to define time step at start of each load step.
OFF
Use NSBSTP to define time step at start of each load step.

ON - Use final time step from previous load step as the starting time step (if
automatic time stepping is used).
ON
Use final time step from previous load step as the starting time step (if
automatic time stepping is used).

Notes
-----
See DELTIM for an alternative input. It is recommended that all fields
See ``DELTIM`` for an alternative input. It is recommended that all fields
of this command be specified for solution efficiency and robustness.

When the arc-length method is active (ARCLEN command), the NSBMX and
NSBMN arguments are ignored.
When the arc-length method is active (``ARCLEN`` command), the ``NSBMX`` and
``NSBMN`` arguments are ignored.

This command is also valid in PREP7.
"""
Expand All @@ -510,11 +515,13 @@ def numexp(self, num="", begrng="", endrng="", elcalc="", **kwargs):
num
The number of solutions to expand. This value is required.

Num - Number of solutions to expand.
Num
Number of solutions to expand.

ALL - Expand all substeps between BEGRNG and ENDRNG (provided that ENDRNG > 0). If
BEGRNG and ENDRNG have no specified values, this option
expands all substeps of all load steps.
ALL
Expand all substeps between ``BEGRNG`` and ``ENDRNG`` (provided that ENDRNG > 0). If
``BEGRNG`` and ``ENDRNG`` have no specified values, this option
expands all substeps of all load steps.

begrng, endrng
Beginning and ending time (or frequency) range for expanded
Expand All @@ -523,43 +530,45 @@ def numexp(self, num="", begrng="", endrng="", elcalc="", **kwargs):
elcalc
The element-calculation key:

YES - Calculate element results, nodal loads, and reaction loads. This value is the
default.
YES
Calculate element results, nodal loads, and reaction loads. This value is the
default.

NO - Do not calculate these items.
NO
Do not calculate these items.

Notes
-----
Specifies a range of solutions to be expanded from analyses that use
mode-superposition methods (ANTYPE,HARMIC or TRANS) or substructuring
(ANTYPE,SUBSTR).
mode-superposition methods (``ANTYPE,HARMIC`` or ``TRANS``) or substructuring
(``ANTYPE,SUBSTR``).

For ANTYPE,TRANS, NUM, evenly spaced solutions are expanded between
time BEGRNG and time ENDRNG.
time BEGRNG and time ``ENDRNG``.

For ANTYPE,HARMIC, NUM, evenly spaced solutions are expanded between
frequency BEGRNG and frequency ENDRNG.
frequency BEGRNG and frequency ``ENDRNG``.

The first expansion in all cases is done at the first point beyond
BEGRNG (that is, at BEGRNG + (ENDRNG - BEGRNG) / NUM)).
BEGRNG (that is, at ``BEGRNG + (ENDRNG - BEGRNG) / NUM``)).

The resulting results file will maintain the same load step, substep,
and time (or frequency) values as the use pass.

For a single expansion of a solution, or for multiple expansions when
the solutions are not evenly spaced (such as in a mode-superposition
harmonic analysis with the cluster option), ANSYS, Inc. recommends
issuing one or more EXPSOL commands.
issuing one or more ``EXPSOL`` commands.

The NUMEXP command is invalid in these cases:

In a substructing analysis (ANTYPE,SUBST) when a factorized matrix file
(the .LN22 file generated by the sparse solver) does not exist, causing
In a substructing analysis (``ANTYPE,SUBST``) when a factorized matrix file
(the ``.LN22`` file generated by the sparse solver) does not exist, causing
ANSYS to employ the full-resolve method.

If the full-resolve option is selected using the SEOPT command.
If the full-resolve option is selected using the ``SEOPT`` command.

In both situations, use the EXPSOL command to perform a single
In both situations, use the ``EXPSOL`` command to perform a single
expansion for each solution desired.

This command is also valid in PREP7.
Expand Down
24 changes: 23 additions & 1 deletion src/ansys/mapdl/core/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,31 @@ def time_values(self) -> np.ndarray:
75.20949687626468]
"""
self._mapdl.post1(mute=True)
list_rsp = self._mapdl.set("LIST")
with self._mapdl.run_as_routine("POST1"):
list_rsp = self._mapdl.set("LIST")
return np.genfromtxt(list_rsp.splitlines(), skip_header=3)[:, 1]

@property
def frequency_values(self) -> np.ndarray:
"""Return an array of the frequency values for all result sets.

Returns
-------
numpy.ndarray
Frequency values for all result sets.

Examples
--------
Get all the time values after loading POST1.

>>> mapdl.post1()
>>> mapdl.post_processing.frequency_values
array([ 220., 240., 260., 280., 300., 320., 340., 360., 380.,
400., 420., 440.])
"""
# Because in MAPDL it is the same.
return self.time_values

def _reset_cache(self):
"""Reset local cache"""
self._set_loaded = False
Expand Down
12 changes: 12 additions & 0 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,18 @@ def test_general_plotter_returns(mapdl, static_solve):
)


def test_time_frequency_values(mapdl, contact_solve):
assert np.allclose(
mapdl.post_processing.time_values, mapdl.post_processing.frequency_values
)


def test_time_values(mapdl, contact_solve):
assert np.allclose(
mapdl.post_processing.time_values, np.array([0.2, 0.4, 0.7, 1.0])
)


###############################################################################
# @pytest.mark.parametrize('comp', COMPONENT_STRESS_TYPE)
# def test_nodal_thermal_component_strain(mapdl, thermal_solve, comp):
Expand Down