Class SpreadsheetBlock
java.lang.Object
neqsim.util.NamedBaseClass
neqsim.process.SimulationBaseClass
neqsim.process.equipment.ProcessEquipmentBaseClass
neqsim.process.equipment.util.SpreadsheetBlock
- All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, ProcessElementInterface, SimulationInterface, NamedInterface
Inline spreadsheet / calculator block for embedding custom calculations directly in a flowsheet.
Similar to UniSim's spreadsheet, this block lets users define named import cells that pull values
from process streams or equipment, named formula cells that perform arithmetic on those values,
and export cells that push computed results back into the process.
Usage example:
SpreadsheetBlock sheet = new SpreadsheetBlock("Energy Calc");
sheet.addStreamImportCell("T_in", feed, s -> s.getTemperature("C"));
sheet.addStreamImportCell("T_out", product, s -> s.getTemperature("C"));
sheet.addStreamImportCell("mdot", feed, s -> s.getFlowRate("kg/hr"));
sheet.addFormulaCell("deltaT", cells -> cells.get("T_out") - cells.get("T_in"));
sheet.addFormulaCell("duty_kW",
cells -> cells.get("mdot") * 4.18 * cells.get("deltaT") / 3600.0);
sheet.addExportCell("duty_kW", cooler, (eq, val) -> ((Cooler) eq).setEnergyInput(val));
- Version:
- 1.0
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceBase interface for cell definitions.private static classCell with a constant value.private static classInternal record for export targets.static interfaceFunctional interface for writing a computed value to process equipment.private static classCell computed by a formula referencing other cells.private static classCell that reads from process equipment.private static classCell that reads from a stream. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedHashMap<String, SpreadsheetBlock.CellDefinition> Ordered map of cell names to their definitions.private final LinkedHashMap<String, Double> Current computed values for each cell.private final List<SpreadsheetBlock.ExportTarget> Export targets that push computed values back into the process.private static final org.apache.logging.log4j.LoggerLogger object for class.private static final longSerialization version UID.Fields inherited from class ProcessEquipmentBaseClass
conditionAnalysisMessage, energyStream, hasController, isSolved, properties, reportFields inherited from class SimulationBaseClass
calcIdentifier, calculateSteadyState, timeFields inherited from class NamedBaseClass
name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConstantCell(String cellName, double value) Add a constant cell with a fixed value.voidaddExportCell(String cellName, ProcessEquipmentInterface target, SpreadsheetBlock.ExportWriter writer) Add an export target that pushes a computed cell value back into process equipment after calculation.voidAdd a formula cell that computes a value from the current cell values.voidaddImportCell(String cellName, ProcessEquipmentInterface equipment, Function<ProcessEquipmentInterface, Double> reader) Add an import cell that reads a value from any process equipment each time the block runs.voidaddStreamImportCell(String cellName, StreamInterface stream, Function<StreamInterface, Double> reader) Add an import cell that reads a value from a stream each time the block runs.Get all current cell values as an unmodifiable map.Get the names of all defined cells in order.doublegetCellValue(String cellName) Get the current computed value of a cell.voidIn this method all thermodynamic and unit operations will be calculated in a steady state calculation.Methods inherited from class ProcessEquipmentBaseClass
addCapacityConstraint, addController, copy, displayResult, equals, getAvailableMargin, getAvailableMarginPercent, getBottleneckConstraint, getCapacityConstraints, getConditionAnalysisMessage, getConstraintEvaluationReport, getController, getController, getControllers, getEffectiveCapacityFactor, getEnergyStream, getEntropyProduction, getExergyChange, getFailureMode, getMassBalance, getMassBalance, getMaxUtilization, getMaxUtilizationPercent, getMechanicalDesign, getMinimumFlow, getPressure, getPressure, getProperty, getReferenceDesignation, getReport_json, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, getUtilizationSummary, hashCode, initElectricalDesign, initializeDefaultConstraints, initInstrumentDesign, initMechanicalDesign, isActive, isActive, isCapacityAnalysisEnabled, isCapacityExceeded, isFailed, isHardLimitExceeded, isNearCapacityLimit, isSetEnergyStream, reportResults, restoreFromFailure, run_step, runConditionAnalysis, setCapacityAnalysisEnabled, setController, setEnergyStream, setEnergyStream, setFailureMode, setFlowValveController, setMinimumFlow, setPressure, setReferenceDesignation, setRegulatorOutSignal, setSpecification, setTemperature, simulateDegradedOperation, simulateTrip, solved, toJson, toJsonMethods inherited from class SimulationBaseClass
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTimeMethods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumberMethods inherited from interface ProcessEquipmentInterface
getCapacityDuty, getCapacityMax, getElectricalDesign, getEquipmentState, getExergyChange, getExergyDestruction, getExergyDestruction, getFluid, getInletStreams, getInstrumentDesign, getOperatingEnvelopeViolation, getOutletFlowRate, getOutletPressure, getOutletStreams, getOutletTemperature, getReferenceDesignationString, getRestCapacity, getSimulationValidationErrors, isSimulationValid, isWithinOperatingEnvelope, needRecalculation, validateSetupMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, runTransient, runTransient, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTime
-
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. -
cells
Ordered map of cell names to their definitions. -
cellValues
Current computed values for each cell. -
exportTargets
Export targets that push computed values back into the process.
-
-
Constructor Details
-
SpreadsheetBlock
-
-
Method Details
-
addStreamImportCell
public void addStreamImportCell(String cellName, StreamInterface stream, Function<StreamInterface, Double> reader) Add an import cell that reads a value from a stream each time the block runs.- Parameters:
cellName- unique name for this cell (e.g. "T_inlet")stream- the source stream to read fromreader- function that extracts a double value from the stream
-
addImportCell
public void addImportCell(String cellName, ProcessEquipmentInterface equipment, Function<ProcessEquipmentInterface, Double> reader) Add an import cell that reads a value from any process equipment each time the block runs.- Parameters:
cellName- unique name for this cellequipment- the source equipment to read fromreader- function that extracts a double value from the equipment
-
addConstantCell
Add a constant cell with a fixed value.- Parameters:
cellName- unique name for this cellvalue- the constant value
-
addFormulaCell
Add a formula cell that computes a value from the current cell values. Formula cells can reference any previously defined cell (import, constant, or earlier formula cells).- Parameters:
cellName- unique name for this cellformula- function that takes the map of current cell values and returns the computed value
-
addExportCell
public void addExportCell(String cellName, ProcessEquipmentInterface target, SpreadsheetBlock.ExportWriter writer) Add an export target that pushes a computed cell value back into process equipment after calculation.- Parameters:
cellName- the cell whose value to exporttarget- the equipment to receive the valuewriter- biconsumer that applies the value to the equipment
-
getCellValue
Get the current computed value of a cell.- Parameters:
cellName- the cell name- Returns:
- the current value, or
Double.NaNif not yet computed
-
getAllCellValues
-
getCellNames
-
run
In this method all thermodynamic and unit operations will be calculated in a steady state calculation.
- Parameters:
id- UUID
-