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

Small fixes in Krylov example #2322

Merged
merged 3 commits into from
Sep 11, 2023
Merged
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
67 changes: 35 additions & 32 deletions doc/source/examples/extended_examples/Krylov/krylov_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ These are the main steps required:

Perform required imports
------------------------
Perform required imports and launch MAPDL.
Perform required imports and launch MAPDL.

.. code:: ipython3

Expand Down Expand Up @@ -224,22 +224,33 @@ Get the first 10 natural frequency modes of the acoustic duct.
A = mm.mat(k.nrow, nev)
eigenvalues = mm.eigs(nev, k, M, phi=A, fmin=1.0)

for each_freq in range(10):
print(f"Freq = {eigenvalues[each_freq]:8.2f} Hz") # Eigenfrequency (Hz)

The first ten modes are:

+-------------+----------------+
| Mode number | Frequency (Hz) |
+=============+================+
| 1 | 83.33 |
+-------------+----------------+
| 2 | 250.00 |
+-------------+----------------+
| 3 | 416.67 |
+-------------+----------------+
| 4 | 583.34 |
+-------------+----------------+
| 5 | 750.03 |
+-------------+----------------+
| 6 | 916.74 |
+-------------+----------------+
| 7 | 1083.49 |
+-------------+----------------+
| 8 | 1250.32 |
+-------------+----------------+
| 9 | 1417.26 |
+-------------+----------------+
| 10 | 1584.36 |
+-------------+----------------+

.. parsed-literal::

Freq = 83.33 Hz
Freq = 250.00 Hz
Freq = 416.67 Hz
Freq = 583.34 Hz
Freq = 750.03 Hz
Freq = 916.74 Hz
Freq = 1083.49 Hz
Freq = 1250.32 Hz
Freq = 1417.26 Hz
Freq = 1584.36 Hz


Run harmonic analysis using Krylov method
Expand Down Expand Up @@ -273,15 +284,11 @@ frequency-sweep Krylov method.

Obtain the shape of the generated subspace.

.. code:: ipython3

print(Qz.shape)


.. parsed-literal::
.. code:: pycon

>>> print(Qz.shape)
(3240, 10)


**Step 3**: Reduce the system of equations and solve at each frequency
from 0 Hz to 1000 Hz with ramped loading.
Expand All @@ -292,15 +299,11 @@ from 0 Hz to 1000 Hz with ramped loading.

Obtain the shape of the reduced solution generated.

.. code:: ipython3

print(Yz.shape)


.. parsed-literal::
.. code:: pycon

>>> print(Yz.shape)
(10, 100)


**Step 4**: Expand the reduced solution back to the FE space.

Expand Down Expand Up @@ -340,12 +343,12 @@ Load the last result substep to get the pressure for each of the selected nodes.
# Get pressure at the node
pressure = get_pressure_at(each_node, substep_index)['x'][0]

#Calculate amplitude at 60 deg
# Calculate amplitude at 60 deg
magnitude = abs(pressure)
phase = math.atan2(pressure.imag, pressure.real)
pressure_a = magnitude * np.cos(np.deg2rad(60)+phase)

# Store result for later plotting
# Store result for later plotting
x_data.append(loc[0]) # X-Coordenate
y_data.append(pressure_a) # Nodal pressure at 60 degrees

Expand Down Expand Up @@ -435,4 +438,4 @@ Plot the frequency response function for the selected node.
plt.show()


.. image:: files/file_38_0.png
.. image:: files/file_38_0.png