FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Samplifier

Sample and hold.

+ Collaboration diagram for Samplifier:
Author
Joakim Haugen

Samplifier is a SimObject that samples the input signals in a sample-and-hold fashion. It can simulate a variety of real-world properties in the sampled signal. The following things can be configured to happen with the output signals:

The samples are taken at the fixed instants FirstSampleTime + k * SamplingPeriod (the first sample time when FirstSampleTime is not given), each on the first step at or after the instant. An instant that falls inside a step is not made up, so the schedule does not drift with the step size (owner ruling D23).

The random draws use std::normal_distribution and std::uniform_real_distribution on a std::mt19937 seeded with NoiseSeed. The engine is portable, but the standard leaves the distributions' transforms to the library, so a given NoiseSeed reproduces the same sequence with one standard library only. Other libraries give a different sequence with the same statistics.

Example configuration excerpt

<Lib
LibName = "fhsim_base"
SimObject = "Signal/Samplifier"
Name = "Sample"
PortWidth = "1"
NoiseSeed = "42"
Tags = "OutVector1"
SamplingPeriod1 = "1, 1, 1"
FirstSampleTime1 = "0.9999,0.9999,0.9999"
TimeDelay1 = "0, 0, 0"
OutlierProbability1= "0, 0, 0.01"
LossProbability1 = "0, 0, 0.1"
AvgLostSamples1 = "0, 0, 3"
NoiseBias1 = "0, 0, 0.1"
NoiseStdDev1 = "1, 1, 2"
/>

Input Ports

Name Width Description
In1 .. In<PortWidth> n_i Vector inputs. The dimension of each input is inferred from the configuration parameter's dimension.

Output Ports

Name Width Description
Out1 .. Out<PortWidth> n_i Vector outputs samplified.
<Tags> <PortWidth> Named outputs (Optional).

Configuration parameters

Name Width Description
NoiseSeed 0 or 1 Seed number for random generator (Optional).
PortWidth 1 Number of std::vector input signals.
Tags <PortWidth> or 0 Named output ports (Optional).
SamplingPeriod<1..PortWidth> n_i List of positive sampling periods (a period of zero or less is an error).
FirstSampleTime<1..PortWidth> n_i or 0 List of first available sample times. Note that the sample will be available on the first time step after the sampling instant. Default is the time of the first sample.
TimeDelay<1..PortWidth> n_i or 0 List of non-negative time delays. Default is zeros.
OutlierProbability<1..PortWidth> n_i or 0 List of probabilities for outliers. Default is zeros.
LossProbability<1..PortWidth> n_i or 0 List of probabilities for loss of signal. Default is zeros.
AvgLostSamples<1..PortWidth> n_i or 0 List of average number of lost signals (when loss). Default is zeros.
NoiseBias<1..PortWidth> n_i or 0 List of bias (mean) for each noisy output. Default is zeros.
NoiseStdDev<1..PortWidth> n_i or 0 List of standard deviations. Default is zeros.

Initial conditions

Name Width Description
SamplifierDummy 1 Internal placeholder state with zero derivative. It carries no meaning, is set to 0 by InitialConditionSetup, and need not be given in the model.

Full example file

<Contents>
<OBJECTS>
<Lib
LibName = "fhsim_base"
SimObject = "Signal/Samplifier"
Name = "S"
PortWidth = "1"
NoiseSeed = "42"
Tags = "OutVector1"
SamplingPeriod1 = "1, 1, 1"
FirstSampleTime1 = "0.9999,0.9999,0.9999"
TimeDelay1 = "0, 0, 0"
OutlierProbability1= "0, 0, 0.01"
LossProbability1 = "0, 0, 0.1"
AvgLostSamples1 = "0, 0, 3"
NoiseBias1 = "0, 0, 0.1"
NoiseStdDev1 = "1, 1, 2"
/>
<Lib
LibName = "fhsim_base"
SimObject = "Src/Random"
Name = "R"
PortWidth = "3"
RandomType = "VariableRandom"
RandomMin = "0.2, 0.2, 0.2"
RandomMax = "1.2, 1.2, 1.2"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
S.In1 = "R.Out"
/>
</INTERCONNECTIONS>
<INITIALIZATION>
<InitialCondition
/>
</INITIALIZATION>
<SIMULATION>
<Timing TStart="0" TEnd="30"/>
<Integrator Method="RK45_i" NumCores="1" LogStates="1" UseRSSNorm="0">
<StepControl StepMax="0.002" StepMin="0.00000001" AbsTol="1e-3" RelTol="1e-3"/>
</Integrator>
</SIMULATION>
</Contents>

This SimObject is referred to as Signal/Samplifier