Class TimeIntegrator
java.lang.Object
neqsim.process.equipment.pipeline.twophasepipe.numerics.TimeIntegrator
- All Implemented Interfaces:
Serializable
Time integration methods for the two-fluid transient pipe model.
Provides explicit time stepping algorithms with CFL-based adaptive time step control. The primary method is the classical 4th-order Runge-Kutta (RK4) scheme.
RK4 Algorithm
For dU/dt = R(U):
- k1 = R(U^n)
- k2 = R(U^n + 0.5*dt*k1)
- k3 = R(U^n + 0.5*dt*k2)
- k4 = R(U^n + dt*k3)
- U^{n+1} = U^n + dt/6 * (k1 + 2*k2 + 2*k3 + k4)
CFL Condition
The time step is limited by: dt ≤ CFL * dx / (|v| + c) where c is the sound speed and CFL is typically 0.5-0.9 for explicit schemes.
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIntegration method type.static interfaceInterface for the right-hand side function (spatial discretization). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleCFL number for time step control (0 < CFL < 1).private doubleCurrent time step (s).private doubleCurrent simulation time (s).private doubleMaximum allowed time step (s).private TimeIntegrator.MethodCurrent integration method.private doubleMinimum allowed time step (s).private static final long -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TimeIntegrator(TimeIntegrator.Method method) Constructor with method selection. -
Method Summary
Modifier and TypeMethodDescriptionprivate double[][]addArrays(double[][] A, double[][] B) Add two 2D arrays element-wise.voidadvanceTime(double dt) Advance current time by dt.doublecalcStableTimeStep(double maxWaveSpeed, double dx) Calculate stable time step based on CFL condition.doublecalcTwoFluidTimeStep(double[] gasVelocities, double[] liquidVelocities, double[] gasSoundSpeeds, double[] liquidSoundSpeeds, double dx) Calculate stable time step for two-fluid system.doubleGet CFL number.doubleGet current time step.doubleGet current simulation time.doubleGet maximum time step.Get integration method.doubleGet minimum time step.voidreset()Reset integrator state.private double[][]scaleArray(double[][] A, double s) Scale a 2D array by a scalar.voidsetCflNumber(double cflNumber) Set CFL number.voidsetCurrentTime(double currentTime) Set current simulation time.voidsetMaxTimeStep(double maxTimeStep) Set maximum time step.voidsetMethod(TimeIntegrator.Method method) Set integration method.voidsetMinTimeStep(double minTimeStep) Set minimum time step.double[][]step(double[][] U, TimeIntegrator.RHSFunction rhs, double dt) Advance solution by one time step using selected method.double[][]stepEuler(double[][] U, TimeIntegrator.RHSFunction rhs, double dt) Forward Euler method (first-order).double[][]stepRK2(double[][] U, TimeIntegrator.RHSFunction rhs, double dt) Second-order Runge-Kutta (Heun's method).double[][]stepRK4(double[][] U, TimeIntegrator.RHSFunction rhs, double dt) Classical 4th-order Runge-Kutta.double[][]stepSSPRK3(double[][] U, TimeIntegrator.RHSFunction rhs, double dt) Strong Stability Preserving RK3 (Shu-Osher).
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
method
Current integration method. -
cflNumber
private double cflNumberCFL number for time step control (0 < CFL < 1). -
minTimeStep
private double minTimeStepMinimum allowed time step (s). -
maxTimeStep
private double maxTimeStepMaximum allowed time step (s). -
currentTime
private double currentTimeCurrent simulation time (s). -
currentDt
private double currentDtCurrent time step (s).
-
-
Constructor Details
-
TimeIntegrator
public TimeIntegrator()Default constructor. -
TimeIntegrator
Constructor with method selection.- Parameters:
method- Integration method
-
-
Method Details
-
step
Advance solution by one time step using selected method.- Parameters:
U- Current state [nCells][nVars]rhs- Right-hand side functiondt- Time step- Returns:
- Updated state at t + dt
-
stepEuler
Forward Euler method (first-order).U^{n+1} = U^n + dt * R(U^n)
- Parameters:
U- Current staterhs- Right-hand side functiondt- Time step- Returns:
- Updated state
-
stepRK2
Second-order Runge-Kutta (Heun's method).- Parameters:
U- Current staterhs- Right-hand side functiondt- Time step- Returns:
- Updated state
-
stepRK4
Classical 4th-order Runge-Kutta.- Parameters:
U- Current staterhs- Right-hand side functiondt- Time step- Returns:
- Updated state
-
stepSSPRK3
Strong Stability Preserving RK3 (Shu-Osher).Maintains TVD property, good for problems with shocks.
- Parameters:
U- Current staterhs- Right-hand side functiondt- Time step- Returns:
- Updated state
-
calcStableTimeStep
public double calcStableTimeStep(double maxWaveSpeed, double dx) Calculate stable time step based on CFL condition.- Parameters:
maxWaveSpeed- Maximum wave speed in the domain (|v| + c)dx- Minimum cell size- Returns:
- Stable time step
-
calcTwoFluidTimeStep
public double calcTwoFluidTimeStep(double[] gasVelocities, double[] liquidVelocities, double[] gasSoundSpeeds, double[] liquidSoundSpeeds, double dx) Calculate stable time step for two-fluid system.- Parameters:
gasVelocities- Gas velocities at each cell (m/s)liquidVelocities- Liquid velocities at each cell (m/s)gasSoundSpeeds- Gas sound speeds at each cell (m/s)liquidSoundSpeeds- Liquid sound speeds at each cell (m/s)dx- Cell size (m)- Returns:
- Stable time step
-
advanceTime
public void advanceTime(double dt) Advance current time by dt.- Parameters:
dt- Time step taken
-
addArrays
private double[][] addArrays(double[][] A, double[][] B) Add two 2D arrays element-wise.- Parameters:
A- First arrayB- Second array- Returns:
- A + B
-
scaleArray
private double[][] scaleArray(double[][] A, double s) Scale a 2D array by a scalar.- Parameters:
A- Arrays- Scalar- Returns:
- s * A
-
getMethod
-
setMethod
Set integration method.- Parameters:
method- New method
-
getCflNumber
public double getCflNumber()Get CFL number.- Returns:
- CFL number
-
setCflNumber
public void setCflNumber(double cflNumber) Set CFL number.- Parameters:
cflNumber- New CFL number (0 < CFL < 1)
-
getMinTimeStep
public double getMinTimeStep()Get minimum time step.- Returns:
- Minimum time step (s)
-
setMinTimeStep
public void setMinTimeStep(double minTimeStep) Set minimum time step.- Parameters:
minTimeStep- Minimum time step (s)
-
getMaxTimeStep
public double getMaxTimeStep()Get maximum time step.- Returns:
- Maximum time step (s)
-
setMaxTimeStep
public void setMaxTimeStep(double maxTimeStep) Set maximum time step.- Parameters:
maxTimeStep- Maximum time step (s)
-
getCurrentTime
public double getCurrentTime()Get current simulation time.- Returns:
- Current time (s)
-
setCurrentTime
public void setCurrentTime(double currentTime) Set current simulation time.- Parameters:
currentTime- Current time (s)
-
getCurrentDt
public double getCurrentDt()Get current time step.- Returns:
- Current time step (s)
-
reset
public void reset()Reset integrator state.
-