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

Add Newmark integrator in time response method #1032

Merged
merged 25 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
819bccd
Add Newmark integration algorithm to obtain time response
jguarato Dec 12, 2023
47abf40
Add docstring to newmark method
jguarato Dec 13, 2023
160a186
Change newmark integration for updating matrices with speed variation
jguarato Dec 15, 2023
7d98a3d
Change newmark function variable names
jguarato Dec 18, 2023
a4dad57
Merge branch 'main' into dev-newmark-integration
jguarato Jan 15, 2024
915e5c3
Merge branch 'main' into dev-newmark-integrator
jguarato Jan 23, 2024
a4dff93
Arrange Newmark integration into new function
jguarato Jan 23, 2024
390ddcc
Merge branch 'main' into dev-newmark-integrator
jguarato Jan 24, 2024
554a453
Add example to integrate_rotor_system function in utils
jguarato Jan 24, 2024
83974c2
Merge branch 'main' into dev-newmark-integrator
jguarato Jan 30, 2024
ef1aea2
Fix progress interval of newmark method
jguarato Feb 7, 2024
f7e51bd
Merge branch 'main' into dev-newmark-integrator
jguarato Feb 27, 2024
8b8f02f
Update matrix name after merge
jguarato Feb 27, 2024
8f51ef8
Fix progress interval in newmark method
jguarato Feb 27, 2024
8dfeab3
Change the check for speed to be array in the integration method
jguarato Feb 27, 2024
4a7a252
Add pseudo-modal method to integration
jguarato Feb 27, 2024
dfb3ffb
Add pseudo-modal method to integration
jguarato Feb 27, 2024
0c97ffc
Adjust some prints
jguarato Feb 29, 2024
c8f60a9
Fix apply_pseudo_modal doctest
jguarato Mar 1, 2024
350f380
Fix apply_pseudo_modal doctest expected result
jguarato Mar 1, 2024
8a1cd65
Create separated function to assemble C and K matrices
jguarato Mar 13, 2024
d846186
Add ext_forces to numerical integration
jguarato Mar 14, 2024
ddab0c4
Add details in docstrings for numerical integration
jguarato Mar 14, 2024
ddf46d1
Merge branch 'main' into dev-newmark-integrator
jguarato Mar 28, 2024
ab38719
Merge branch 'main' into dev-newmark-integrator
Apr 25, 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
47 changes: 39 additions & 8 deletions ross/rotor_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)
from ross.shaft_element import ShaftElement, ShaftElement6DoF
from ross.units import Q_, check_units
from ross.utils import intersection
from ross.utils import intersection, integrate_rotor_system

__all__ = ["Rotor", "CoAxialRotor", "rotor_example", "coaxrotor_example"]

Expand Down Expand Up @@ -1927,20 +1927,32 @@ def run_unbalance_response(

return forced_response

def time_response(self, speed, F, t, ic=None):
def time_response(self, speed, F, t, ic=None, integrator="default", **kwargs):
"""Time response for a rotor.

This method returns the time response for a rotor
given a force, time and initial conditions.

Parameters
----------
speed : float or array_like
Rotor speed. Automatically, the Newmark method is chosen if `speed`
has an array_like type.
F : array
Force array (needs to have the same length as time array).
t : array
Time array. (must have the same length than lti.B matrix)
ic : array, optional
The initial conditions on the state vector (zero by default).
integrator : str, optional
The Newmark method can be chosen by setting `integrator='newmark'`.
**kwargs : optional
Additional keyword arguments can be passed to define the parameters
of the Newmark method if it is used (e.g. gamma, beta, tol, ...).
See `ross.utils.newmark` for more details.
Other keyword arguments can also be passed to be used in numerical
integration (e.g. num_modes, add_to_RHS).
See `ross.utils.integrate_rotor_system` for more details.

Returns
-------
Expand All @@ -1961,8 +1973,15 @@ def time_response(self, speed, F, t, ic=None):
>>> rotor.time_response(speed, F, t) # doctest: +ELLIPSIS
(array([0. , 0.18518519, 0.37037037, ...
"""
lti = self._lti(speed)
return signal.lsim(lti, F, t, X0=ic)
speed_is_array = isinstance(speed, (list, tuple, np.ndarray))

if speed_is_array or integrator.lower() == "newmark":
t_, yout = integrate_rotor_system(self, speed, F, t, **kwargs)
return t_, yout, []

else:
lti = self._lti(speed)
return signal.lsim(lti, F, t, X0=ic)

def plot_rotor(self, nodes=1, check_sld=False, length_units="m", **kwargs):
"""Plot a rotor object.
Expand Down Expand Up @@ -2434,7 +2453,7 @@ def run_level1(self, n=5, stiffness_range=None, num=5, **kwargs):

return results

def run_time_response(self, speed, F, t):
def run_time_response(self, speed, F, t, integrator="default", **kwargs):
"""Calculate the time response.

This function will take a rotor object and calculate its time response
Expand All @@ -2447,13 +2466,23 @@ def run_time_response(self, speed, F, t):

Parameters
----------
speed : float
Rotor speed.
speed : float or array_like
Rotor speed. Automatically, the Newmark method is chosen if `speed`
has an array_like type.
F : array
Force array (needs to have the same number of rows as time array).
Each column corresponds to a dof and each row to a time.
t : array
Time array.
integrator : str, optional
The Newmark method can be chosen by setting `integrator='newmark'`.
**kwargs : optional
Additional keyword arguments can be passed to define the parameters
of the Newmark method if it is used (e.g. gamma, beta, tol, ...).
See `ross.utils.newmark` for more details.
Other keyword arguments can also be passed to be used in numerical
integration (e.g. num_modes, add_to_RHS).
See `ross.utils.integrate_rotor_system` for more details.

Returns
-------
Expand Down Expand Up @@ -2483,7 +2512,9 @@ def run_time_response(self, speed, F, t):
>>> # plot orbit response - plotting 3D orbits - full rotor model:
>>> fig3 = response.plot_3d()
"""
t_, yout, xout = self.time_response(speed, F, t)
t_, yout, xout = self.time_response(
speed, F, t, integrator=integrator, **kwargs
)

results = TimeResponseResults(self, t, yout, xout)

Expand Down
Loading
Loading