Skip to content

Defining time-varying loads

Many physics interactions in Allsolve — Load, Lump V/Q, Lump I/V, Constraint, and others — accept an expression field for the driving value. This expression can be a constant, a variable, or a time-dependent function built from the expressions listed below.

By default, many example projects use wavelet() for transient excitation, but Allsolve provides a broader set of signal functions that may better suit your simulation.

Function Shape Typical use
sin(2*pi*freq*t) Continuous sinusoid Steady-state AC excitation
sn(n) Shortcut for sin(2*pi*f*n*t), where f is fundamental frequency Harmonic / multiharmonic driving
cn(n) Shortcut for cos(2*pi*f*n*t), where f is fundamental frequency Phase-shifted harmonic driving
wavelet(freq, delay) Ricker wavelet (band-limited pulse) Transient broadband excitation
ramp(up, hold, down, delay) Trapezoidal or triangular 0 → 1 → 0 Gradual loading / unloading
ramps(up, hold, down, delay, period, repeats) Repeating trapezoidal/triangular Cyclic loading
pulse(up, down, delay) Rectangular 0 / 1 Switching, on/off driving
pulses(up, down, delay, repeats) Repeating rectangular Pulse trains

All of these functions depend on the time variable t. They can be scaled, combined, and used inside any expression field.

Use sin() and cos() to build continuous sinusoidal signals. These are the standard trigonometric functions and take an argument in radians.

A typical AC voltage or current drive:

sin(2 * pi * freq * t)

where freq is a variable defined by the user in the Common sidebar.

You can scale the amplitude and add a DC offset:

V_dc + V_ac * sin(2 * pi * freq * t)

sn(n) and cn(n) are shortcuts for harmonic driving signals:

  • sn(n) expands to sin(2 * pi * f * n * t)
  • cn(n) expands to cos(2 * pi * f * n * t)

The frequency f is the simulation frequency set in the Simulations section — you do not need to define it as a variable.

These are mainly used with harmonic and multiharmonic analysis types. For example, driving a lumped port at the fundamental frequency:

sn(1)

Or exciting the second harmonic:

sn(2)

wavelet(frequency, delay) generates a Ricker wavelet — a compact, band-limited pulse centered around the given frequency. It is the most common choice for transient simulations where you want broadband excitation to capture the impulse response of a device.

wavelet(freq, 1.0)

The delay parameter is not in seconds — it specifies the delay as a multiple of the time period T=1/fT = 1/f. A delay of 1.0 shifts the wavelet peak to t=Tt = T.

Example usage for driving a piezocomposite transducer via Lump V/Q:

wavelet(frequency, 1.2)

or for a SAW unit cell:

wavelet(freq, 1.0)

ramp(rampuptime, holdtime, rampdowntime, delay) creates a single trapezoidal/triangular signal that transitions from 0 to 1 and back to 0. All time values are in seconds.

ramp(3, 5, 3, 0)

This signal:

  1. Starts at 0 with no delay.
  2. Ramps linearly from 0 to 1 over 3 seconds.
  3. Holds at 1 for 5 seconds.
  4. Ramps linearly from 1 to 0 over 3 seconds.
  5. Stays at 0 afterwards indefinitely.

To scale it, multiply by the desired amplitude:

1000 * ramp(0.01, 0.1, 0.01, 0)

ramps(rampuptime, holdtime, rampdowntime, delay, period, repeats) repeats the ramp pattern. Set repeats to -1 for infinite repetition.

ramps(2, 3, 2, 1, 10, 5)

This creates 5 cycles of a ramp that starts at t=1 st = 1\:\text{s}, each cycle fitting within a 10-second period.

pulse(pulseuptime, pulsedowntime, delay) creates a single rectangular pulse — a sharp transition between 0 and 1 with no ramp.

pulse(2, 3, 1)

This signal jumps to 1 at t=1 st = 1\:\text{s}, stays high for 2 seconds, drops to 0, stays low for 3 seconds, then remains at 0.

pulses(pulseuptime, pulsedowntime, delay, repeats) creates a repeating pulse train. Set repeats to -1 for infinite repetition.

pulses(2, 3, 1, 4)

All signal functions return a dimensionless value (typically between -1 and 1, or 0 and 1). Scale them and combine them in expressions to match your physical setup:

Goal Expression
10 V sinusoidal voltage 10 * sin(2*pi*freq*t)
5 V DC + 1 V AC ripple 5 + 1 * sin(2*pi*freq*t)
Ramped sinusoid ramp(0.01, 1, 0, 0) * sin(2*pi*freq*t)
Pulsed wavelet burst pulse(0.001, 0.01, 0) * wavelet(freq, 0.5)
Analysis type Recommended functions Why
Transient wavelet(), sin(), ramp(), pulse() The solver steps through time, so time-dependent expressions are evaluated directly.
Harmonic sn(1), cn(1) The solver assumes a single-frequency steady state. sn(1) provides the fundamental driving signal.
Multiharmonic sn(n), cn(n) with multiple harmonics The solver captures multiple harmonics simultaneously. Use sn(1), sn(2), etc. to excite specific harmonics.
Static Constant values or variables No time dependence — use a fixed value like 1000 or a variable.
Eigenmode Typically not driven Eigenmode analysis finds natural frequencies without external excitation.

Load expressions are entered in the expression field of a physics interaction. The exact field depends on the interaction type:

Interaction Expression field Example
Load (Solid mechanics) Force vector [0; 0; -200*sn(1)]
Lump V/Q (Electrostatics) Voltage or Charge wavelet(frequency, 1.2)
Lump I/V (Current flow) Current or Voltage sn(1)
Lump I/V cut (Current flow) Current or Voltage I * sin(2*pi*freq*t)
Constraint (Electrostatics) Voltage sin(2*pi*freq*t)
Pressure (Solid mechanics) Scalar pressure 1e6 * ramp(0.01, 0.1, 0.01, 0)

For the complete list of interactions per physics, see the individual physics reference pages — for example Solid mechanics or Electrostatics.

For detailed parameter descriptions, see the Expressions reference. The Script API reference documents equivalent Python functions (qs.wavelet(), qs.sin(), qs.ramp(), etc.) for use in scripted simulations.