Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact runTransient. Default to steady state calculation #417

Merged
merged 5 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ neqsim.iml
.DS_Store

# Test output - Serialized files
test_*.ser
test_*.ser

.dccache
24 changes: 24 additions & 0 deletions src/main/java/neqsim/processSimulation/SimulationBaseClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@

public abstract class SimulationBaseClass extends NamedBaseClass implements SimulationInterface {
private static final long serialVersionUID = 1L;
private boolean calculateSteadyState = true;

public SimulationBaseClass(String name) {
super(name);
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
if (getCalculateSteadyState()) {
run();
return;
}

throw new UnsupportedOperationException("RunTransient using difference equations is not supported yet.");
}

/** {@inheritDoc} */
@Override
public boolean getCalculateSteadyState() {
return calculateSteadyState;
}

/** {@inheritDoc} */
@Override
public void setCalculateSteadyState(boolean steady) {
this.calculateSteadyState = steady;
}
}
77 changes: 46 additions & 31 deletions src/main/java/neqsim/processSimulation/SimulationInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,52 @@
import neqsim.util.NamedInterface;

public interface SimulationInterface extends NamedInterface, Runnable {
/**
* <p>
* run
* </p>
* In this method all thermodynamic and unit the operation will be calculated in
* a steady state
* calculation.
*
* @return void
*/
@Override
public void run();
/**
* Get calculateSteadyState
*
* @return Value of property calculateSteadyState
*/
public boolean getCalculateSteadyState();

/**
* <p>
* runTransient
* </p>
* In this method all thermodynamic and unit the operation will be calculated in
* a dynamic
* calculation. dt is the delta time step (seconds)
*
* @return void
*/
public void runTransient(double dt);
/**
* Setter for property calculateSteadyState
*
* @param steady Set true to do steady state calculation when calling runTransient.
*/
public void setCalculateSteadyState(boolean steady);

/**
* <p>
* solved.
* </p>
*
* @return a boolean
*/
public boolean solved();
/**
* <p>
* run
* </p>
* In this method all thermodynamic and unit operations will be calculated in a steady state
* calculation.
*
* @return void
*/
@Override
public void run();

/**
* <p>
* runTransient
* </p>
* This method calculates thermodynamic and unit operations using
* difference equations if available and calculateSteadyState is true.
* Use setCalculateSteadyState to set the parameter.
*
* @param dt is the delta time step (seconds)
*
* @return void
*/
public void runTransient(double dt);

/**
* <p>
* solved.
* </p>
*
* @return a boolean
*/
public boolean solved();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ public ProcessEquipmentBaseClass(String name) {
super(name);
}

/** {@inheritDoc} */
@Override
public void run() {}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
run();
}

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,6 @@ public void displayResult() {
outStream[1].displayResult();
}

/**
* <p>
* runTransient.
* </p>
*/
@Override
public void runTransient(double dt) {
}

/** {@inheritDoc} */
@Override
public void setAproachToEquilibrium(double eff) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.util.ArrayList;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
Expand Down Expand Up @@ -254,11 +256,6 @@ public StreamInterface getSolventInStream() {
return solventInStream;
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
}

/**
* <p>
* calcEa.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.util.ArrayList;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
Expand Down Expand Up @@ -241,11 +243,6 @@ public StreamInterface getSolventInStream() {
return solventInStream;
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
}

/**
* <p>
* calcEa.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ public void displayResult() {
outStream[1].displayResult();
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
}

/**
* <p>
* setAproachToEquilibrium.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.util.Objects;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
Expand Down Expand Up @@ -843,10 +846,6 @@ public double getTotalWork() {
return multi * (getThermoSystem().getEnthalpy() - inletEnthalpy);
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}

/** {@inheritDoc} */
@Override
public double getIsentropicEfficiency() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ public void run() {
setTemperature(mixedStream.getTemperature());
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}

/**
* <p>
* getGasOutStream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public void run() {
// outStream.setThermoSystem(mixedStream.getThermoSystem());
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}

/** {@inheritDoc} */
@Override
public StreamInterface getGasOutStream() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import java.awt.FlowLayout;
import java.text.DecimalFormat;
import java.text.FieldPosition;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
Expand Down Expand Up @@ -218,9 +220,5 @@ public void displayResult() {
dialogContentPane.add(scrollpane);
dialog.pack();
dialog.setVisible(true);
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ public void displayResult() {
getOutStream().displayResult();
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}

/**
* <p>
* Getter for the field <code>energyInput</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public void displayResult() {
System.out.println("out Temperature " + reboilerDuty);
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
}

/**
* <p>
* Getter for the field <code>reboilerDuty</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
import java.text.FieldPosition;
import java.util.ArrayList;
import java.util.Objects;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
Expand Down Expand Up @@ -200,12 +203,6 @@ public StreamInterface getOutStream() {
return mixedStream;
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
run();
}

/** {@inheritDoc} */
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,5 @@ public void run() {
testOps.PHflash(enthalpy, 0);
// System.out.println("temp " + mixedStream.getThermoSystem().getTemperature());
mixedStream.getThermoSystem().init(3);
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,6 @@ public void displayResult() {
system.display();
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
run();
}

/** {@inheritDoc} */
@Override
public FlowSystemInterface getPipe() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ public void displayResult() {
system.display();
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
run();
}

/** {@inheritDoc} */
@Override
public FlowSystemInterface getPipe() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ public void displayResult() {
System.out.println("Superficial velocity out MEG/water : " + getSuperficialVelocity(2, 1));
}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
}

/** {@inheritDoc} */
@Override
public FlowSystemInterface getPipe() {
Expand Down
Loading