Vertical models#

Exitation#

Exitation#

This module provides functions to generate excitation signals, commonly used in simulations. These functions include sinusoidal signals, both in their full form and selectively capturing only positive or negative parts, as well as other custom excitation signals.

pymycar.VerticalModels.exitations.bump_exitation(t, amplitude, frequency)[source]#

Generate a bump excitation signal.

The bump signal is a sinusoidal signal that is active only for a fraction of its period (up to half of the period).

Parameters:
tarray_like

Time values.

amplitudefloat

Amplitude of the bump signal.

frequencyfloat

Frequency of the bump signal.

Returns:
array_like

Bump excitation signal.

Examples

>>> t = np.linspace(0, 2, 1000)
>>> signal = bump_exitation(t, 1, 1)
pymycar.VerticalModels.exitations.from_data(t, defined_time, defined_sol)[source]#

Interpolate an excitation signal from defined data points.

Parameters:
tarray_like

Time values for which the signal is to be interpolated.

defined_timearray_like

Time values where the signal is defined.

defined_solarray_like

Signal values corresponding to defined_time.

Returns:
array_like

Interpolated signal at the given time values.

Examples

>>> defined_time = [0, 1, 2, 3]
>>> defined_sol = [0, 10, 5, 0]
>>> t = np.linspace(0, 3, 100)
>>> signal = from_data(t, defined_time, defined_sol)
pymycar.VerticalModels.exitations.sin_exitation(t, amplitude, frequency)[source]#

Generate a sinusoidal excitation signal.

Parameters:
tarray_like

Time values.

amplitudefloat

Amplitude of the sinusoidal signal.

frequencyfloat

Frequency of the sinusoidal signal.

Returns:
array_like

Sinusoidal excitation signal.

Examples

>>> t = np.linspace(0, 10, 1000)
>>> signal = sin_exitation(t, 1, 0.2)
pymycar.VerticalModels.exitations.sin_negative_part_exitation(t, amplitude, frequency)[source]#

Generate a sinusoidal excitation signal with only the negative part.

Parameters:
tarray_like

Time values.

amplitudefloat

Amplitude of the sinusoidal signal.

frequencyfloat

Frequency of the sinusoidal signal.

Returns:
array_like

Sinusoidal excitation signal with negative values only.

Examples

>>> t = np.linspace(0, 10, 1000)
>>> signal = sin_negative_part_exitation(t, -0.1, 0.2)
pymycar.VerticalModels.exitations.sin_possitive_part_exitation(t, amplitude, frequency)[source]#

Generate a sinusoidal excitation signal with only the positive part.

Parameters:
tarray_like

Time values.

amplitudefloat

Amplitude of the sinusoidal signal.

frequencyfloat

Frequency of the sinusoidal signal.

Returns:
array_like

Sinusoidal excitation signal with positive values only.

Examples

>>> t = np.linspace(0, 10, 1000)
>>> signal = sin_possitive_part_exitation(t, 0.1, 0.2)

Models#

class pymycar.VerticalModels.models.VerticalCar(mycar, custom_excitation, time_points)[source]#

Bases: object

Methods

get_F_vector

get_damper_matrix

get_mass_matrix

get_stiffness_matrix

plot_results

solve

system

get_F_vector(t)[source]#
get_damper_matrix()[source]#
get_mass_matrix()[source]#
get_stiffness_matrix()[source]#
number_dofs = 7#
plot_results()[source]#
solve()[source]#
system(y, t)[source]#
class pymycar.VerticalModels.models.VerticalHalfCar(mycar, custom_excitation, time_points, part='front')[source]#

Bases: object

Methods

get_F_vector

get_damper_matrix

get_mass_matrix

get_stiffness_matrix

solve

system

get_F_vector(t)[source]#
get_damper_matrix()[source]#
get_mass_matrix()[source]#
get_stiffness_matrix()[source]#
number_dofs = 4#
solve()[source]#
system(y, t)[source]#
class pymycar.VerticalModels.models.VerticalQuarterCar(mycar, quarter_part='right_front', result_folder_name='results', path=None)[source]#

Bases: object

Simulate a vertical quarter car model and save results to a text file.

Parameters:#

custom_excitationfunction

Custom excitation function.

time_pointsarray-like

Time points for simulation.

Attributes:#

number_dofsint

Number of degrees of freedom (constant).

Methods

get_F_vector(t)

Get the force vector at time t.

get_damper_matrix()

Get the damper matrix.

get_mass_matrix()

Get the mass matrix.

get_stiffness_matrix()

Get the stiffness matrix.

save_2_text_file([filename])

Save results to a text file.

solve()

Solve the differential equations.

system(t, y)

System of differential equations.

natural_frequencies

get_F_vector(t)[source]#

Get the force vector at time t.

Parameters:#

tfloat

Current time.

Returns:#

np.ndarray

Force vector.

get_damper_matrix()[source]#

Get the damper matrix.

Returns:#

np.ndarray

Damper matrix.

get_mass_matrix()[source]#

Get the mass matrix.

Returns:#

np.ndarray

Mass matrix.

get_stiffness_matrix()[source]#

Get the stiffness matrix.

Returns:#

np.ndarray

Stiffness matrix.

natural_frequencies()[source]#
number_dofs = 2#
save_2_text_file(filename='data.txt')[source]#

Save results to a text file.

Parameters:#

filenamestr, optional

Name of the output text file (default is ‘data.txt’).

solve()[source]#

Solve the differential equations.

Returns:#

np.ndarray

Solution array.

system(t, y)[source]#

System of differential equations.

Parameters:#

ynp.ndarray

State vector.

tfloat

Current time.

Returns:#

np.ndarray

Derivative of the state vector.

pymycar.VerticalModels.models.solver(system, time_points, initial_conditions)[source]#

Solve the differential equations.