Class TransferFunctionBlock
java.lang.Object
neqsim.util.NamedBaseClass
neqsim.process.controllerdevice.TransferFunctionBlock
- All Implemented Interfaces:
Serializable, ControllerDeviceInterface, ProcessElementInterface, NamedInterface
Transfer function block for representing control dynamics in dynamic simulation. Supports
first-order lag, lead-lag, pure dead time (transport delay), and second-order dynamics. These are
the fundamental building blocks used in control system design and simulation.
The transfer function is represented in the Laplace domain as:
- First-order lag: G(s) = K / (tau*s + 1)
- Lead-lag: G(s) = K * (tauLead*s + 1) / (tauLag*s + 1)
- Dead time: G(s) = K * exp(-theta*s)
- Second-order: G(s) = K / (tau1*s + 1)(tau2*s + 1)
Example — lead-lag compensator for a feedforward signal:
TransferFunctionBlock leadLag =
new TransferFunctionBlock("FF-comp", TransferFunctionBlock.Type.LEAD_LAG);
leadLag.setGain(1.0);
leadLag.setLeadTime(30.0); // 30 seconds lead
leadLag.setLagTime(120.0); // 120 seconds lag
leadLag.setTransmitter(flowTransmitter);
process.add(leadLag);
- Version:
- 1.0
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTransfer function types supported by this block.Nested classes/interfaces inherited from interface ControllerDeviceInterface
ControllerDeviceInterface.ControllerMode, ControllerDeviceInterface.StepResponseTuningMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected UUIDUUID from last calculation.private doubleDead time (transport delay) theta [s].private double[]Circular buffer for dead time implementation.private intWrite index for dead time buffer.private doubleStatic gain K.private booleanFlag indicating whether internal states have been initialized.private doubleInput bias (steady-state input value).private booleanWhether block is active.private doubleFirst time constant (tau for first-order, tauLag for lead-lag, tau1 for second-order) [s].private doubleSecond time constant (tau2 for second-order) [s].private doubleLead time constant (tauLead for lead-lag) [s].private static final org.apache.logging.log4j.LoggerLogger object for class.private doubleCurrent output value.private doubleOutput bias (steady-state output value).private static final longSerialization version UID.private doubleState for first-order lag filter (or lag portion of lead-lag).private doubleState for second time constant (second-order only).private MeasurementDeviceInterfaceAttached transmitter providing the input signal.private final TransferFunctionBlock.TypeTransfer function type.private StringEngineering unit.Fields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionTransferFunctionBlock(String name, TransferFunctionBlock.Type type) Constructor for TransferFunctionBlock. -
Method Summary
Modifier and TypeMethodDescriptionprivate doubleapplyDeadTime(double currentValue, double dt) Apply dead time via circular buffer.private doublecomputeDeadTime(double u, double dt) Pure dead time: stores the input in a circular buffer and reads out the delayed value.private doublecomputeFirstOrderLag(double u, double dt) First-order lag: y(k) = alpha * y(k-1) + (1 - alpha) * K * u(k) where alpha = tau / (tau + dt).private doublecomputeLeadLag(double u, double dt) Lead-lag: implemented as a first-order lag plus a derivative lead correction.private doublecomputeSecondOrder(double u, double dt) Second-order system: cascade of two first-order lags.doublegetControllerSetPoint.doubleGet the dead time [s].doublegetGain()Get the static gain K.doubleGet the input bias.doubleGet the primary lag time constant [s].doubleGet the second lag time constant [s].doubleGet the lead time constant [s].doublegetMeasuredValue.doubleGet the current output value.doubleGet the output bias.doublegetResponse.getType()Get the transfer function type.getUnit()getUnit.private voidinitializeStates(double u, double dt) booleanisActive()isActive.booleanisReverseActing.voidreset()Reset internal states to initial conditions.voidrunTransient(double initResponse, double dt, UUID id) runTransient.voidsetActive(boolean isActive) setActive.voidsetControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.voidsetControllerSetPoint(double signal) setControllerSetPoint.voidsetDeadTime(double deadTime) Set the dead time (transport delay) [s].voidsetGain(double gain) Set the static gain K.voidsetInputBias(double inputBias) Set the input bias (steady-state input around which the transfer function is linearized).voidsetLagTime(double lagTime) Set the primary lag time constant [s].voidsetLagTime2(double lagTime2) Set the second lag time constant for SECOND_ORDER type [s].voidsetLeadTime(double leadTime) Set the lead time constant for LEAD_LAG type [s].voidsetOutputBias(double outputBias) Set the output bias (steady-state output value).voidsetReverseActing(boolean reverseActing) setReverseActing.voidsetTransmitter.voidsetUnit.Methods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ControllerDeviceInterface
addGainSchedulePoint, autoTune, autoTune, autoTuneFromEventLog, autoTuneFromEventLog, autoTuneStepResponse, autoTuneStepResponse, equals, getEventLog, getIntegralAbsoluteError, getManualOutput, getMeasuredValue, getMode, getSetpointWeight, getSettlingTime, getStepResponseTuningMethod, hashCode, resetEventLog, resetPerformanceMetrics, runTransient, setControllerSetPoint, setDerivativeFilterTime, setManualOutput, setMode, setOutputLimits, setSetpointWeight, setStepResponseTuningMethodMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumber
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
type
Transfer function type. -
gain
private double gainStatic gain K. -
lagTime
private double lagTimeFirst time constant (tau for first-order, tauLag for lead-lag, tau1 for second-order) [s]. -
leadTime
private double leadTimeLead time constant (tauLead for lead-lag) [s]. -
lagTime2
private double lagTime2Second time constant (tau2 for second-order) [s]. -
deadTime
private double deadTimeDead time (transport delay) theta [s]. -
inputBias
private double inputBiasInput bias (steady-state input value). -
outputBias
private double outputBiasOutput bias (steady-state output value). -
state1
private double state1State for first-order lag filter (or lag portion of lead-lag). -
state2
private double state2State for second time constant (second-order only). -
deadTimeBuffer
private double[] deadTimeBufferCircular buffer for dead time implementation. -
deadTimeWriteIndex
private int deadTimeWriteIndexWrite index for dead time buffer. -
initialized
private boolean initializedFlag indicating whether internal states have been initialized. -
output
private double outputCurrent output value. -
transmitter
Attached transmitter providing the input signal. -
unit
Engineering unit. -
isActive
private boolean isActiveWhether block is active. -
calcIdentifier
UUID from last calculation.
-
-
Constructor Details
-
TransferFunctionBlock
Constructor for TransferFunctionBlock.- Parameters:
name- identifier for this blocktype- the type of transfer function
-
-
Method Details
-
getType
-
setGain
public void setGain(double gain) Set the static gain K.- Parameters:
gain- the gain value
-
getGain
public double getGain()Get the static gain K.- Returns:
- the gain
-
setLagTime
public void setLagTime(double lagTime) Set the primary lag time constant [s]. For FIRST_ORDER_LAG this is tau. For LEAD_LAG this is tauLag. For SECOND_ORDER this is tau1.- Parameters:
lagTime- time constant in seconds (must be positive)
-
getLagTime
public double getLagTime()Get the primary lag time constant [s].- Returns:
- lag time in seconds
-
setLeadTime
public void setLeadTime(double leadTime) Set the lead time constant for LEAD_LAG type [s].- Parameters:
leadTime- time constant in seconds (must be non-negative)
-
getLeadTime
public double getLeadTime()Get the lead time constant [s].- Returns:
- lead time in seconds
-
setLagTime2
public void setLagTime2(double lagTime2) Set the second lag time constant for SECOND_ORDER type [s].- Parameters:
lagTime2- time constant in seconds (must be positive)
-
getLagTime2
public double getLagTime2()Get the second lag time constant [s].- Returns:
- second lag time in seconds
-
setDeadTime
public void setDeadTime(double deadTime) Set the dead time (transport delay) [s].- Parameters:
deadTime- delay in seconds (must be non-negative)
-
getDeadTime
public double getDeadTime()Get the dead time [s].- Returns:
- dead time in seconds
-
setInputBias
public void setInputBias(double inputBias) Set the input bias (steady-state input around which the transfer function is linearized).- Parameters:
inputBias- the bias value
-
getInputBias
public double getInputBias()Get the input bias.- Returns:
- the input bias
-
setOutputBias
public void setOutputBias(double outputBias) Set the output bias (steady-state output value).- Parameters:
outputBias- the bias value
-
getOutputBias
public double getOutputBias()Get the output bias.- Returns:
- the output bias
-
getOutput
public double getOutput()Get the current output value.- Returns:
- the output
-
reset
public void reset()Reset internal states to initial conditions. -
getMeasuredValue
public double getMeasuredValue()getMeasuredValue.
- Specified by:
getMeasuredValuein interfaceControllerDeviceInterface- Returns:
- a double
-
setControllerSetPoint
public void setControllerSetPoint(double signal) setControllerSetPoint.
- Specified by:
setControllerSetPointin interfaceControllerDeviceInterface- Parameters:
signal- a double
-
getControllerSetPoint
public double getControllerSetPoint()getControllerSetPoint.
- Specified by:
getControllerSetPointin interfaceControllerDeviceInterface- Returns:
- current controller set point
-
getUnit
getUnit.
- Specified by:
getUnitin interfaceControllerDeviceInterface- Returns:
- a
Stringobject
-
setUnit
setUnit.
- Specified by:
setUnitin interfaceControllerDeviceInterface- Parameters:
unit- aStringobject
-
setTransmitter
setTransmitter.
- Specified by:
setTransmitterin interfaceControllerDeviceInterface- Parameters:
device- aMeasurementDeviceInterfaceobject
-
runTransient
runTransient.
Calculates controller output. Sets calc identifier UUID.- Specified by:
runTransientin interfaceControllerDeviceInterface- Parameters:
initResponse- Init value for response calculationdt- Delta time [s]id- Calculation identifier
-
getResponse
public double getResponse()getResponse.
- Specified by:
getResponsein interfaceControllerDeviceInterface- Returns:
- a double
-
isReverseActing
public boolean isReverseActing()isReverseActing.
- Specified by:
isReverseActingin interfaceControllerDeviceInterface- Returns:
- a boolean
-
setReverseActing
public void setReverseActing(boolean reverseActing) setReverseActing.
- Specified by:
setReverseActingin interfaceControllerDeviceInterface- Parameters:
reverseActing- a boolean
-
setControllerParameters
public void setControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.
- Specified by:
setControllerParametersin interfaceControllerDeviceInterface- Parameters:
Kp- Proportional gainTi- Integral time in secondsTd- Derivative time in seconds
-
setActive
public void setActive(boolean isActive) setActive.
Set if controller is active- Specified by:
setActivein interfaceControllerDeviceInterface- Parameters:
isActive- Set true to make controller active.
-
isActive
public boolean isActive()isActive.
Specifies if controller is active- Specified by:
isActivein interfaceControllerDeviceInterface- Returns:
- a boolean
-
initializeStates
private void initializeStates(double u, double dt) -
computeFirstOrderLag
private double computeFirstOrderLag(double u, double dt) First-order lag: y(k) = alpha * y(k-1) + (1 - alpha) * K * u(k) where alpha = tau / (tau + dt).- Parameters:
u- the input signal valuedt- the time step in seconds- Returns:
- the filtered output value
-
computeLeadLag
private double computeLeadLag(double u, double dt) Lead-lag: implemented as a first-order lag plus a derivative lead correction. Discretized as: y(k) = (tauLead/tauLag) * K * u(k) + (1 - tauLead/tauLag) * lagFiltered(K*u).- Parameters:
u- the input signal valuedt- the time step in seconds- Returns:
- the lead-lag filtered output value
-
computeDeadTime
private double computeDeadTime(double u, double dt) Pure dead time: stores the input in a circular buffer and reads out the delayed value.- Parameters:
u- the input signal valuedt- the time step in seconds- Returns:
- the delayed output value
-
computeSecondOrder
private double computeSecondOrder(double u, double dt) Second-order system: cascade of two first-order lags. G(s) = K / (tau1*s + 1)(tau2*s + 1)- Parameters:
u- the input signal valuedt- the time step in seconds- Returns:
- the second-order filtered output value
-
applyDeadTime
private double applyDeadTime(double currentValue, double dt) Apply dead time via circular buffer.- Parameters:
currentValue- the current signal value to delaydt- the time step in seconds- Returns:
- the delayed output value from the circular buffer
-