Explicit space-time excitation¶
This executable example shows the complete contract: the caller defines both axes, a load generates a field, and the beam solver projects it.
In [1]:
Copied!
import matplotlib.pyplot as plt
import numpy as np
import dynaresp as dr
time = np.arange(600, dtype=float) / 200.0
positions = np.linspace(0.0, 5.0, 101)
beam = dr.systems.Beam(
length=5.0,
material="steel",
section=("rectangular", 0.10, 0.02),
n_elements=20,
n_modes=5,
)
import matplotlib.pyplot as plt
import numpy as np
import dynaresp as dr
time = np.arange(600, dtype=float) / 200.0
positions = np.linspace(0.0, 5.0, 101)
beam = dr.systems.Beam(
length=5.0,
material="steel",
section=("rectangular", 0.10, 0.02),
n_elements=20,
n_modes=5,
)
/home/runner/work/DynaResp/DynaResp/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .autonotebook import tqdm as notebook_tqdm
In [2]:
Copied!
vehicle = dr.loads.TwoWheelLoad(
front_load=-4000.0, rear_load=-3500.0, speed=2.5, wheel_spacing=1.25
)
history = vehicle.generate(time, positions)
assert history.values.shape == (positions.size, time.size)
assert np.max(np.count_nonzero(history.values, axis=0)) <= 2
plt.pcolormesh(time, positions, history.values, shading="auto")
plt.xlabel("Time [s]")
plt.ylabel("Position [m]")
plt.colorbar(label="Force [N]")
plt.show()
vehicle = dr.loads.TwoWheelLoad(
front_load=-4000.0, rear_load=-3500.0, speed=2.5, wheel_spacing=1.25
)
history = vehicle.generate(time, positions)
assert history.values.shape == (positions.size, time.size)
assert np.max(np.count_nonzero(history.values, axis=0)) <= 2
plt.pcolormesh(time, positions, history.values, shading="auto")
plt.xlabel("Time [s]")
plt.ylabel("Position [m]")
plt.colorbar(label="Force [N]")
plt.show()
In [3]:
Copied!
spec = dr.SimulationSpec(
system=beam,
load=vehicle,
sensors=(dr.sensors.Accelerometer(position=2.5),),
time=time,
positions=positions,
)
result = dr.run_simulation(spec, seed=42)
plt.plot(result.time, result.signal[0])
plt.xlabel("Time [s]")
plt.ylabel("Acceleration")
plt.show()
spec = dr.SimulationSpec(
system=beam,
load=vehicle,
sensors=(dr.sensors.Accelerometer(position=2.5),),
time=time,
positions=positions,
)
result = dr.run_simulation(spec, seed=42)
plt.plot(result.time, result.signal[0])
plt.xlabel("Time [s]")
plt.ylabel("Acceleration")
plt.show()
result.positions is the supplied physical axis, result.load_values is the original field, and result.force is its modal projection. No beam grid is requested by the load.