Class PlugFlowReactor

All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, TwoPortInterface, ProcessElementInterface, SimulationInterface, NamedInterface

public class PlugFlowReactor extends TwoPortEquipment
Plug flow reactor (PFR) for rigorous kinetic modeling of chemical reactions.

Models chemical transformation along a tubular reactor by solving coupled ordinary differential equations for species molar flows, temperature, and pressure as a function of axial position. The reactor supports homogeneous gas-phase and heterogeneous catalytic reactions with multiple reaction types (power-law, LHHW, reversible).

Governing Equations

  • Species balance: dFi/dz = Ac * sum(nu_ij * r_j)
  • Energy balance: dT/dz = (-sum(r_j * dH_j) * Ac + U*pi*D*(Tc-T)) / sum(Fi*Cp_i)
  • Pressure drop: dP/dz from Ergun equation (packed bed) or friction factor (empty tube)

Operating Modes

Supported energy modes
Mode Description
ADIABATIC No heat transfer; T changes from reaction enthalpy only
ISOTHERMAL T held constant; heat duty calculated
COOLANT Heat exchange with coolant at Tc via overall U

Integration Methods

  • Forward Euler (simple, first-order)
  • Classical 4th-order Runge-Kutta (RK4, default, higher accuracy)

Usage Example

// Create reaction
KineticReaction rxn = new KineticReaction("A to B");
rxn.addReactant("methane", 1, 1.0);
rxn.addProduct("hydrogen", 2);
rxn.setPreExponentialFactor(1e10);
rxn.setActivationEnergy(150000.0);
rxn.setHeatOfReaction(-75000.0);

// Configure catalyst
CatalystBed catalyst = new CatalystBed();
catalyst.setParticleDiameter(3.0, "mm");
catalyst.setVoidFraction(0.40);
catalyst.setBulkDensity(800.0);

// Build reactor
PlugFlowReactor pfr = new PlugFlowReactor("PFR-1", feedStream);
pfr.addReaction(rxn);
pfr.setCatalystBed(catalyst);
pfr.setLength(5.0, "m");
pfr.setDiameter(0.10, "m");
pfr.setEnergyMode(PlugFlowReactor.EnergyMode.ADIABATIC);
pfr.run();

double conversion = pfr.getConversion();
ReactorAxialProfile profile = pfr.getAxialProfile();
Version:
1.0
Author:
esol
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
      Logger object for class.
    • length

      private double length
      Reactor tube length [m].
    • diameter

      private double diameter
      Reactor tube inner diameter [m].
    • numberOfTubes

      private int numberOfTubes
      Number of parallel tubes (multi-tube reactor).
    • reactions

      private List<KineticReaction> reactions
      List of kinetic reactions.
    • catalystBed

      private CatalystBed catalystBed
      Catalyst bed properties (null for homogeneous reactors).
    • energyMode

      private PlugFlowReactor.EnergyMode energyMode
      Energy balance mode.
    • coolantTemperature

      private double coolantTemperature
      Coolant temperature [K] (used in COOLANT mode).
    • overallHeatTransferCoefficient

      private double overallHeatTransferCoefficient
      Overall heat transfer coefficient U [W/(m2*K)] (used in COOLANT mode).
    • numberOfSteps

      private int numberOfSteps
      Number of integration steps.
    • integrationMethod

      private PlugFlowReactor.IntegrationMethod integrationMethod
      Integration method.
    • propertyUpdateFrequency

      private int propertyUpdateFrequency
      Re-flash thermodynamic properties every N steps.
    • keyComponent

      private String keyComponent
      Key component name for conversion tracking.
    • axialProfile

      private ReactorAxialProfile axialProfile
      Axial profile results.
    • overallConversion

      private double overallConversion
      Overall conversion of key component [-].
    • heatDuty

      private double heatDuty
      Total heat duty [W] (positive = heat added, negative = heat removed).
    • pressureDrop

      private double pressureDrop
      Total pressure drop [bar].
    • outletTemperatureK

      private double outletTemperatureK
      Outlet temperature [K].
    • residenceTime

      private double residenceTime
      Mean residence time [s].
  • Constructor Details

    • PlugFlowReactor

      public PlugFlowReactor(String name)
      Constructor for PlugFlowReactor.
      Parameters:
      name - equipment name
    • PlugFlowReactor

      public PlugFlowReactor(String name, StreamInterface inletStream)
      Constructor for PlugFlowReactor with inlet stream.
      Parameters:
      name - equipment name
      inletStream - the inlet feed stream
  • Method Details

    • run

      public void run(UUID id)

      In this method all thermodynamic and unit operations will be calculated in a steady state calculation.

      Parameters:
      id - UUID
    • calculateDerivatives

      private double[] calculateDerivatives(SystemInterface system, double[] state, int nComp, double totalArea, double perimeter, String[] compNames)
      Calculate derivatives dF/dz, dT/dz, dP/dz for the state vector.
      Parameters:
      system - thermodynamic system for property evaluation
      state - packed state [F1..Fn, T, P]
      nComp - number of components
      totalArea - total cross-sectional area of all tubes [m2]
      perimeter - tube perimeter [m] (single tube)
      compNames - component names
      Returns:
      derivative vector [dF1/dz..dFn/dz, dT/dz, dP/dz]
    • convertRateToVolumetric

      private double convertRateToVolumetric(double rate, KineticReaction rxn)
      Convert reaction rate from its native basis to volumetric basis [mol/(m3_reactor * s)].
      Parameters:
      rate - rate in native units
      rxn - the kinetic reaction
      Returns:
      volumetric rate [mol/(m3_reactor * s)]
    • estimateTotalHeatCapacityFlow

      private double estimateTotalHeatCapacityFlow(SystemInterface system, double[] state, int nComp)
      Estimate total heat capacity flow sum(Fi * Cp_i) [J/(s*K)].
      Parameters:
      system - thermodynamic system
      state - current state vector
      nComp - number of components
      Returns:
      total heat capacity flow [J/(s*K)]
    • getGasDensity

      private double getGasDensity(SystemInterface system)
      Get gas density from the thermodynamic system.
      Parameters:
      system - thermodynamic system
      Returns:
      gas density [kg/m3]
    • getGasViscosity

      private double getGasViscosity(SystemInterface system)
      Get gas viscosity from the thermodynamic system.
      Parameters:
      system - thermodynamic system
      Returns:
      gas dynamic viscosity [Pa*s]
    • getSuperVelocity

      private double getSuperVelocity(SystemInterface system, double totalArea)
      Calculate superficial velocity through the reactor tubes.
      Parameters:
      system - thermodynamic system
      totalArea - total cross-sectional area [m2]
      Returns:
      superficial velocity [m/s]
    • calculateTotalReactionRate

      private double calculateTotalReactionRate(SystemInterface system, String[] compNames)
      Calculate total reaction rate for profile storage.
      Parameters:
      system - thermodynamic system
      compNames - component names
      Returns:
      total absolute reaction rate [mol/(m3*s)]
    • calculateIsothermalHeatDuty

      private double calculateIsothermalHeatDuty(SystemInterface system, double[] molFlows, String[] compNames)
      Calculate isothermal heat duty by summing reaction enthalpies over the reactor.
      Parameters:
      system - thermodynamic system
      molFlows - current molar flows
      compNames - component names
      Returns:
      heat duty [W]
    • calculateResidenceTime

      private double calculateResidenceTime(SystemInterface system, double totalArea)
      Calculate mean residence time.
      Parameters:
      system - thermodynamic system
      totalArea - total cross-sectional area [m2]
      Returns:
      residence time [s]
    • packState

      private double[] packState(double[] molFlows, double temperature, double pressure)
      Pack molar flows, temperature, and pressure into a state vector.
      Parameters:
      molFlows - molar flows [mol/s]
      temperature - temperature [K]
      pressure - pressure [bara]
      Returns:
      state vector [F1..Fn, T, P]
    • unpackState

      private void unpackState(double[] state, double[] molFlows, int nComp)
      Unpack molar flows from state vector.
      Parameters:
      state - state vector
      molFlows - output molar flows array
      nComp - number of components
    • addScaled

      private double[] addScaled(double[] base, double[] delta, double scale)
      Add scaled vector: result[i] = base[i] + scale * delta[i].
      Parameters:
      base - base vector
      delta - delta vector
      scale - scaling factor
      Returns:
      result vector
    • updateSystemState

      private void updateSystemState(SystemInterface system, double[] molFlows, double temperature, double pressure)
      Update the thermodynamic system to reflect current molar flows, T, and P.
      Parameters:
      system - thermodynamic system
      molFlows - current molar flows [mol/s]
      temperature - current temperature [K]
      pressure - current pressure [bara]
    • ensureProductComponentsExist

      private void ensureProductComponentsExist(SystemInterface system)
      Ensure that all product components from reactions exist in the system.
      Parameters:
      system - thermodynamic system to check/update
    • addReaction

      public void addReaction(KineticReaction reaction)
      Add a kinetic reaction to the reactor.
      Parameters:
      reaction - the kinetic reaction to add
    • getReactions

      public List<KineticReaction> getReactions()
      Get the list of reactions.
      Returns:
      list of kinetic reactions
    • setCatalystBed

      public void setCatalystBed(CatalystBed catalystBed)
      Set catalyst bed properties.
      Parameters:
      catalystBed - catalyst bed (null for homogeneous reactor)
    • getCatalystBed

      public CatalystBed getCatalystBed()
      Get catalyst bed properties.
      Returns:
      catalyst bed (null if homogeneous)
    • setLength

      public void setLength(double length, String unit)
      Set reactor tube length.
      Parameters:
      length - length value
      unit - "m", "cm", "ft"
    • getLength

      public double getLength()
      Get reactor tube length [m].
      Returns:
      length in meters
    • setDiameter

      public void setDiameter(double diameter, String unit)
      Set reactor tube inner diameter.
      Parameters:
      diameter - diameter value
      unit - "m", "mm", "cm", "in"
    • getDiameter

      public double getDiameter()
      Get reactor tube inner diameter [m].
      Returns:
      diameter in meters
    • setNumberOfTubes

      public void setNumberOfTubes(int numberOfTubes)
      Set number of parallel tubes.
      Parameters:
      numberOfTubes - number of tubes (1 or more)
    • getNumberOfTubes

      public int getNumberOfTubes()
      Get number of parallel tubes.
      Returns:
      number of tubes
    • setEnergyMode

      public void setEnergyMode(PlugFlowReactor.EnergyMode energyMode)
      Set energy balance mode.
      Parameters:
      energyMode - ADIABATIC, ISOTHERMAL, or COOLANT
    • getEnergyMode

      public PlugFlowReactor.EnergyMode getEnergyMode()
      Get energy balance mode.
      Returns:
      energy mode
    • setCoolantTemperature

      public void setCoolantTemperature(double temperature, String unit)
      Set coolant temperature for COOLANT energy mode.
      Parameters:
      temperature - temperature value
      unit - "K", "C", "F"
    • getCoolantTemperature

      public double getCoolantTemperature()
      Get coolant temperature [K].
      Returns:
      coolant temperature in Kelvin
    • setOverallHeatTransferCoefficient

      public void setOverallHeatTransferCoefficient(double coefficient)
      Set overall heat transfer coefficient for COOLANT mode.
      Parameters:
      coefficient - U [W/(m2*K)]
    • getOverallHeatTransferCoefficient

      public double getOverallHeatTransferCoefficient()
      Get overall heat transfer coefficient [W/(m2*K)].
      Returns:
      U
    • setNumberOfSteps

      public void setNumberOfSteps(int steps)
      Set number of integration steps.
      Parameters:
      steps - number of steps (minimum 10)
    • getNumberOfSteps

      public int getNumberOfSteps()
      Get number of integration steps.
      Returns:
      number of steps
    • setIntegrationMethod

      public void setIntegrationMethod(String method)
      Set integration method.
      Parameters:
      method - "EULER" or "RK4"
    • getIntegrationMethod

      public PlugFlowReactor.IntegrationMethod getIntegrationMethod()
      Get integration method.
      Returns:
      integration method
    • setPropertyUpdateFrequency

      public void setPropertyUpdateFrequency(int frequency)
      Set frequency of thermodynamic property updates.
      Parameters:
      frequency - re-flash every N steps
    • getPropertyUpdateFrequency

      public int getPropertyUpdateFrequency()
      Get property update frequency.
      Returns:
      frequency in steps
    • setKeyComponent

      public void setKeyComponent(String componentName)
      Set key component for conversion tracking.
      Parameters:
      componentName - name of key component (typically limiting reactant)
    • getKeyComponent

      public String getKeyComponent()
      Get key component name.
      Returns:
      key component name
    • getConversion

      public double getConversion()
      Get overall conversion of the key component.
      Returns:
      conversion [0-1]
    • getAxialProfile

      public ReactorAxialProfile getAxialProfile()
      Get the axial profile results.
      Returns:
      reactor axial profile (null if not yet run)
    • getHeatDuty

      public double getHeatDuty()
      Get total heat duty.
      Returns:
      heat duty in Watts (positive = heat added)
    • getHeatDuty

      public double getHeatDuty(String unit)
      Get total heat duty in specified unit.
      Parameters:
      unit - "W", "kW", or "MW"
      Returns:
      heat duty in specified unit
    • getPressureDrop

      public double getPressureDrop()
      Get total pressure drop across the reactor.
      Returns:
      pressure drop [bar]
    • getOutletTemperature

      public double getOutletTemperature()
      Get outlet temperature.
      Specified by:
      getOutletTemperature in interface TwoPortInterface
      Overrides:
      getOutletTemperature in class TwoPortEquipment
      Returns:
      outlet temperature [K]
    • getResidenceTime

      public double getResidenceTime()
      Get mean residence time.
      Returns:
      residence time [s]
    • getSpaceVelocity

      public double getSpaceVelocity()
      Get gas hourly space velocity.
      Returns:
      GHSV [1/hr]
    • getInletStreams

      public List<StreamInterface> getInletStreams()
      Returns all inlet streams connected to this equipment. Subclasses override to report their specific inlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Specified by:
      getInletStreams in interface ProcessEquipmentInterface
      Overrides:
      getInletStreams in class TwoPortEquipment
      Returns:
      unmodifiable list of inlet streams (empty by default)
    • getOutletStreams

      public List<StreamInterface> getOutletStreams()
      Returns all outlet streams produced by this equipment. Subclasses override to report their specific outlets. Used by graph builders, DEXPI export, and auto-instrumentation to discover topology without instanceof checks.
      Specified by:
      getOutletStreams in interface ProcessEquipmentInterface
      Overrides:
      getOutletStreams in class TwoPortEquipment
      Returns:
      unmodifiable list of outlet streams (empty by default)