Simulation API¶
The explicit API puts all inputs for one run in a validated specification:
from dynaresp import SimulationSpec, run_simulation
spec = SimulationSpec(
system=system,
load=load,
sensors=tuple(sensor_layout),
time=time,
positions=positions,
)
result = run_simulation(spec, seed=42)
SimulationSpec
dataclass
¶
Validated configuration for one simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
StructuralSystem
|
Structural strategy providing |
required |
load
|
Load
|
Excitation strategy evaluated on this specification's axes. |
required |
sensors
|
tuple[Sensor, ...]
|
Sensors in result-row order. An empty collection is valid. |
required |
time
|
FloatArray
|
Strictly increasing, uniformly sampled seconds, shape
|
required |
positions
|
FloatArray
|
Strictly increasing reporting and modal-output coordinates,
shape |
required |
The dataclass is frozen. Sensor input is converted to a tuple, and both axes are defensively copied and made read-only so a specification can be reused.
run_simulation ¶
Run an explicit specification without consulting process-wide axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
SimulationSpec
|
Validated system, load, sensors, and numerical axes. |
required |
seed
|
int | None
|
Optional root seed for reproducible stochastic load and sensor effects. |
None
|
rng
|
Generator | None
|
Optional caller-owned NumPy generator. Its state is consumed. Pass
either |
None
|
Returns:
| Type | Description |
|---|---|
SimulationResult
|
Structural states, clean and affected measurements, exact generalized |
SimulationResult
|
force, reporting rasters, modal properties, and serialized metadata. |
Randomness is hierarchical: the root stream creates one independent load
stream and one stream per sensor; each sensor creates one stream per effect.
Thus a fixed spec and seed reproduce results without touching
NumPy's global random state.
Execution order is load generation, exact/distributed force projection, zero-initial-condition response solution, clean sensor sampling, then each sensor's effects in declaration order.
Source code in src/dynaresp/simulation/engine.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
SimulationResult
dataclass
¶
SimulationResult(
time,
positions,
signal,
clean_signal,
displacement,
velocity,
acceleration,
force,
load_values,
mass_matrix,
damping_matrix,
stiffness_matrix,
frequencies,
mode_shapes,
system_properties,
load_properties,
sensor_properties,
point_forces=(),
)
Simulation outputs and the physics needed to interpret them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
FloatArray
|
Simulation time in seconds, shape |
required |
positions
|
FloatArray
|
Reporting/modal positions, shape |
required |
signal
|
FloatArray
|
Sensor measurements after effects, shape
|
required |
clean_signal
|
FloatArray
|
The same sensor rows before effects, shape
|
required |
displacement
|
FloatArray
|
Generalized displacement, shape |
required |
velocity
|
FloatArray
|
Generalized velocity, shape |
required |
acceleration
|
FloatArray
|
Generalized acceleration, shape |
required |
force
|
FloatArray
|
Generalized force actually passed to the solver, shape
|
required |
load_values
|
FloatArray
|
Complete load reporting raster, shape
|
required |
mass_matrix
|
FloatArray
|
Generalized mass matrix, shape |
required |
damping_matrix
|
FloatArray
|
Generalized damping matrix, shape |
required |
stiffness_matrix
|
FloatArray
|
Generalized stiffness matrix, shape |
required |
frequencies
|
FloatArray
|
Natural frequencies in hertz, shape |
required |
mode_shapes
|
FloatArray
|
Physical mode shapes at |
required |
system_properties
|
dict[str, object]
|
JSON-compatible structural configuration. |
required |
load_properties
|
dict[str, object]
|
JSON-compatible generated-load configuration. |
required |
sensor_properties
|
tuple[dict[str, object], ...]
|
Sensor configurations in measurement-row order. |
required |
point_forces
|
tuple[PointForceComponent, ...]
|
Exact point-force trajectories. These, rather than their
nearest-grid representation in |
()
|
With no sensors, signal and clean_signal have shape
(0, n_time); the structural response and ground truth are still present.