Test Data¶
Synthetic measurements for trying the analysis and plotting functions
without hardware. Each create_test_* function returns a DataSet
holding simulated time data (channel 0 is the input, the rest are
responses at 10 kHz), except create_test_bla_captures, which builds the
captures of a Nonlin-stage run.
import pydvma as dvma
data = dvma.create_test_impulse_data()
data.calculate_tf_set(ch_in=0, window=None)
data.plot_tf_data()
Impulse and Noise Tests¶
create_test_impulse_data ¶
Simulate one impulse-hammer test of a single 100 Hz mode.
The DataSet holds one TimeData of 1 s at 10 kHz (10000 samples,
two channels, units ['N', 'm/s']). Channel 0 is the hammer
force: a unit-height raised-cosine pulse, 2 ms long, at the start of
the record (an impulse of 1 mN s). Channel 1 is the VELOCITY it
drives: one mode at 100 Hz whose free decay has a 0.1 s time
constant (damping ratio 0.0159), with modal constant 1000 /kg (a
1 g mass), so the tap sets it moving at about 1 m/s. The response is
the force convolved with the mode's velocity impulse response, so it
starts with the pulse, and a TF of channel 1 over channel 0 is the
velocity FRF: fit it with measurement_type='vel'.
Parameters:
-
noise_level(float, default:0.0) –Half-width of uniform random noise added to channel 1 (default 0, no noise).
Returns:
-
dataset(DataSet) –The simulated measurement, with test name
'Synthesised data'.
create_test_impulse_ensemble ¶
Simulate repeated impulse-hammer tests, for ensemble averaging.
Calls create_test_impulse_data N_ensemble times, so every
measurement is the same 100 Hz mode with fresh random noise on the
response channel.
Parameters:
-
N_ensemble(int, default:5) –Number of measurements (default 5).
-
noise_level(float, default:0.1) –Half-width of the uniform noise added to each response (default 0.1).
Returns:
-
dataset(DataSet) –N_ensembleTimeDatameasurements.
create_test_noise_data ¶
Simulate a random-excitation test of a single 100 Hz mode.
The DataSet holds one TimeData of 10 s at 10 kHz (100000 samples,
two channels, units ['N', 'm/s']). Channel 0 is the input force:
uniform white noise between -0.5 and 0.5 N. Channel 1 is the
velocity it drives in the same structure as
create_test_impulse_data (one mode at 100 Hz, 0.1 s decay time
constant, modal constant 1000 /kg), plus uniform measurement noise.
Parameters:
-
added_noise_level(float, default:0.1) –Half-width of the uniform noise added to channel 1 (default 0.1).
Returns:
-
dataset(DataSet) –The simulated measurement, with test name
'Synthesised data'.
Nonlinear and Multi-Harmonic Responses¶
create_test_impulse_data_nonlinear_v1 ¶
Simulate an impulse test whose decay has two time constants.
The DataSet holds one TimeData of 1 s at 10 kHz (10000 samples,
two channels, units ['N', 'm/s']). Channel 0 is the hammer
force: a unit-height raised-cosine pulse, 2 ms long, at the start of
the record. Channel 1 is the velocity of two coincident 100 Hz modes
with decay time constants 0.05 s and 0.2 s (modal constants 700 and
300 /kg), so its envelope is close to 0.7*exp(-t/0.05) +
0.3*exp(-t/0.2) m/s: a decay that a single damping ratio cannot
describe. The system is linear despite the name; the response is
the force convolved with the modes' velocity impulse responses.
Parameters:
-
noise_level(float, default:0) –Half-width of uniform random noise added to channel 1 (default 0, no noise).
Returns:
-
dataset(DataSet) –The simulated measurement, with test name
'Synthesised nonlinear data v1'.
create_test_impulse_data_nonlinear_v2 ¶
Simulate an impulse test whose frequency falls as it decays.
The DataSet holds one TimeData of 1 s at 10 kHz (10000 samples,
two channels, units ['N', 'm/s']). Channel 0 is the hammer
force: a unit-height raised-cosine pulse, 2 ms long, at the start of
the record. Channel 1 decays as exp(-t/0.1) while
its frequency glides from 200 Hz to 100 Hz along a tanh curve
centred at 0.2 s with a 0.4 s time scale. This one is genuinely
nonlinear, so it has no impulse response to drive with the pulse:
channel 1 is that free decay written down directly, starting at
t = 0. Use it for decay and sonogram analysis, not a TF fit.
Parameters:
-
noise_level(float, default:0) –Half-width of uniform random noise added to channel 1 (default 0, no noise).
Returns:
-
dataset(DataSet) –The simulated measurement, with test name
'Synthesised nonlinear data v2'.
create_test_impulse_data_multi_harmonics ¶
Simulate an impulse test with two families of closely spaced modes.
The DataSet holds one TimeData of 1 s at 10 kHz (10000 samples,
two channels, units ['N', 'm/s']). Channel 0 is a raised-cosine
force pulse 0.5 ms long (unit height) at the start of the record.
Channel 1 is the velocity of modes (decay time constant 0.1 s) at
f1, 4*f1, 9*f1 and 16*f1 (free-decay amplitudes 1,
0.5, 0.3, 0.2 m/s) and at the same multiples of f2 = 1.03*f1
(0.8, 0.4, 0.25, 0.15 m/s), so each pair of modes is 3 % apart:
the force convolved with their velocity impulse responses. Uniform
noise is added to both channels.
Parameters:
-
f1(float, default:100) –Lowest frequency in Hz (default 100).
-
noise_level(float, default:0.001) –Half-width of the uniform noise added to both channels (default 0.001).
Returns:
-
dataset(DataSet) –The simulated measurement, with test name
'Synthesised multi-harmonic data'.
Best Linear Approximation¶
create_test_bla_captures ¶
create_test_bla_captures(M=6, n_exc=2, n_resp=2, N=2048, P=4, t_periods=2, fs=8192.0, k1=8, k2=200, seed=42, amp_rms=0.1, cubic=0.0, noise_rms=0.0001)
Synthesise a complete BLA run against a known MISO system.
Produces the M * n_exc captures of a Schoukens best-linear-
approximation run in the canonical order
[(m, e) for m in range(M) for e in range(n_exc)], ready to hand
straight to analysis.calculate_bla. Every capture is a real
datastructure.TimeData holding the excitation channels first
(indices 0 .. n_exc-1) then the responses (n_exc ..
n_exc+n_resp-1).
The system is
y_r[n] = sum_q (h_qr * x_q)[n] + cubic * (sum_q x_q[n])**3 + e_r[n]
where h_qr is a stable digital peaking biquad (see
_bla_reference_filters), the cubic term is instantaneous — so it
is exactly periodic like the excitation and therefore invisible to
the period-to-period noise estimate, exactly as a real nonlinearity
is — and e_r is white Gaussian output noise of rms
noise_rms, drawn independently for every capture. Excitations
come from acquisition.multisine_generator, so the phase and
scaling law here is the same one analysis.calculate_bla
regenerates in commanded-x mode. The recorded excitation channels
are NOISELESS: the method's noise model is output noise, and a
clean x makes the measured-x and commanded-x paths comparable bit
for bit.
Filtering runs over the whole buffer including the t_periods
transient periods, which the analysis then discards — with the
default geometry the slowest filter has decayed by more than 250 dB
before the first kept period, so the kept data is periodic steady
state to far below the noise floor.
Parameters:
-
M(int, default:6) –Number of realisations (independent phase draws).
-
n_exc(int, default:2) –Number of excitation channels; also the number of experiments per realisation.
-
n_resp(int, default:2) –Number of response channels; independent of
n_exc(non-square systems are supported). -
N(int, default:2048) –Samples in one multisine period.
-
P(int, default:4) –Steady-state periods kept per capture.
-
t_periods(int, default:2) –Transient periods discarded per capture.
-
fs(float, default:8192.0) –Sample rate in Hz.
-
k1(int, default:8) –First excited DFT bin.
-
k2(int, default:200) –Last excited DFT bin.
-
seed(int, default:42) –Master seed for the phase draws and the noise.
-
amp_rms(float, default:0.1) –Per-channel excitation rms in volts.
-
cubic(float, default:0.0) –Coefficient of the instantaneous cubic distortion; 0 gives an exactly linear system.
-
noise_rms(float, default:0.0001) –Standard deviation of the additive white output noise in volts.
Returns:
-
time_data_list(TimeDataList) –The
M * n_exccaptures, each(t_periods + P) * Nsamples long, with units'V'for the excitations and'm/s/s'for the responses. -
run_spec(dict) –The BlaRunSpec describing the run (measured-x mode, x channels
0..n_exc-1, response channels after them), ready foranalysis.calculate_bla. -
G_true(ndarray) –The exact frequency response of the reference filters at the excited bins, complex, shape
(n_k, n_resp, n_exc)withn_k = k2 - k1 + 1, fromscipy.signal.freqzof the same coefficients.