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 physicalproperties #504

Merged
merged 6 commits into from
Jul 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,64 @@
* @version $Id: $Id
*/
public class TestGrunbergNissanFit {
static Logger logger = LogManager.getLogger(TestGrunbergNissanFit.class);
static Logger logger = LogManager.getLogger(TestGrunbergNissanFit.class);

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database
.getResultSet("SELECT * FROM binarysystemviscosity WHERE ComponentName1='TEG'");
// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet =
database.getResultSet("SELECT * FROM binarysystemviscosity WHERE ComponentName1='TEG'");

try {
logger.info("adding....");
while (dataSet.next()) {
GrunbergNissanFunction function = new GrunbergNissanFunction();
double guess[] = {0.001};
function.setInitialGuess(guess);
SystemInterface testSystem = new SystemSrkEos(280, 0.001);
double x1 = Double.parseDouble(dataSet.getString("x1"));
testSystem.addComponent("TEG", x1);
testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2")));
testSystem.createDatabase(true);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature")));
testSystem.init(0);
testSystem.initPhysicalProperties();
double sample1[] = {x1, testSystem.getTemperature()};
double standardDeviation1[] = {0.1};
SampleValue sample =
new SampleValue(Double.parseDouble(dataSet.getString("Viscosity")),
Double.parseDouble(dataSet.getString("StdDev")), sample1,
standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception e) {
logger.error("database error" + e);
}
try {
logger.info("adding....");
while (dataSet.next()) {
GrunbergNissanFunction function = new GrunbergNissanFunction();
double guess[] = {0.001};
function.setInitialGuess(guess);
SystemInterface testSystem = new SystemSrkEos(280, 0.001);
double x1 = Double.parseDouble(dataSet.getString("x1"));
testSystem.addComponent("TEG", x1);
testSystem.addComponent("water", Double.parseDouble(dataSet.getString("x2")));
testSystem.createDatabase(true);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature")));
testSystem.init(0);
testSystem.initPhysicalProperties();
double sample1[] = {x1, testSystem.getTemperature()};
double standardDeviation1[] = {0.1};
SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("Viscosity")),
Double.parseDouble(dataSet.getString("StdDev")), sample1, standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception ex) {
logger.error("database error" + ex);
}

// double sample1[] = {0.1};
// for(int i=0;i<sampleList.size();i++){
// logger.info("ans: " + ((SampleValue)sampleList.get(i)).getFunction().calcValue(sample1));
// }
// double sample1[] = {0.1};
// for(int i=0;i<sampleList.size();i++){
// logger.info("ans: " + ((SampleValue)sampleList.get(i)).getFunction().calcValue(sample1));
// }

SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);
SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);

// do simulations
optim.solve();
// optim.runMonteCarloSimulation();
optim.displayCurveFit();
// optim.displayCurveFit();
optim.writeToTextFile("c:/testFit.txt");
}
// do simulations
optim.solve();
// optim.runMonteCarloSimulation();
optim.displayCurveFit();
// optim.displayCurveFit();
optim.writeToTextFile("c:/testFit.txt");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,64 @@
* @version $Id: $Id
*/
public class TestDiffusivity {
static Logger logger = LogManager.getLogger(TestDiffusivity.class);
static Logger logger = LogManager.getLogger(TestDiffusivity.class);

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryliquiddiffusioncoefficientdata WHERE ComponentSolute='CO2' AND ComponentSolvent='water'");
// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryliquiddiffusioncoefficientdata WHERE ComponentSolute='CO2' AND ComponentSolvent='water'");

try {
logger.info("adding....");
while (dataSet.next()) {
DiffusivityFunction function = new DiffusivityFunction();
double guess[] = {0.001};
function.setInitialGuess(guess);
SystemInterface testSystem = new SystemSrkEos(280, 0.001);
testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0e-10);
testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0);
testSystem.createDatabase(true);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature")));
testSystem.init(0);
testSystem.setPhysicalPropertyModel(4);
testSystem.initPhysicalProperties();
double sample1[] = {testSystem.getTemperature()};
double standardDeviation1[] = {0.1};
SampleValue sample = new SampleValue(
Double.parseDouble(dataSet.getString("DiffusionCoefficient")), 0.01,
sample1, standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception e) {
logger.error("database error" + e);
}
try {
logger.info("adding....");
while (dataSet.next()) {
DiffusivityFunction function = new DiffusivityFunction();
double guess[] = {0.001};
function.setInitialGuess(guess);
SystemInterface testSystem = new SystemSrkEos(280, 0.001);
testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0e-10);
testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0);
testSystem.createDatabase(true);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.setTemperature(Double.parseDouble(dataSet.getString("Temperature")));
testSystem.init(0);
testSystem.setPhysicalPropertyModel(4);
testSystem.initPhysicalProperties();
double sample1[] = {testSystem.getTemperature()};
double standardDeviation1[] = {0.1};
SampleValue sample =
new SampleValue(Double.parseDouble(dataSet.getString("DiffusionCoefficient")), 0.01,
sample1, standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception ex) {
logger.error("database error" + ex);
}

// double sample1[] = {0.1};
// for(int i=0;i<sampleList.size();i++){
// logger.info"ans: " + ((SampleValue)sampleList.get(i)).getFunction().calcValue(sample1));
// }
// double sample1[] = {0.1};
// for(int i=0;i<sampleList.size();i++){
// logger.info"ans: " + ((SampleValue)sampleList.get(i)).getFunction().calcValue(sample1));
// }

SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);
SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);

// do simulations
// optim.solve();
// optim.runMonteCarloSimulation();
//optim.displayGraph();
// optim.writeToTextFile("c:/testFit.txt");
}
// do simulations
// optim.solve();
// optim.runMonteCarloSimulation();
// optim.displayGraph();
// optim.writeToTextFile("c:/testFit.txt");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,64 @@
* @version $Id: $Id
*/
public class TestConductivityFit {
static Logger logger = LogManager.getLogger(TestConductivityFit.class);
static Logger logger = LogManager.getLogger(TestConductivityFit.class);

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
LevenbergMarquardt optim = new LevenbergMarquardt();
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentconductivitydata WHERE ComponentName='TEG'");
// ResultSet dataSet = database.getResultSet("NeqSimDataBase", "SELECT * FROM
// activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");
// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database
.getResultSet("SELECT * FROM purecomponentconductivitydata WHERE ComponentName='TEG'");
// ResultSet dataSet = database.getResultSet("NeqSimDataBase", "SELECT * FROM
// activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");

try {
logger.info("adding....");
while (dataSet.next()) {
ConductivityFunction function = new ConductivityFunction();
double guess[] = {-0.384, 0.00525, -0.00000637};
function.setInitialGuess(guess);
try {
logger.info("adding....");
while (dataSet.next()) {
ConductivityFunction function = new ConductivityFunction();
double guess[] = {-0.384, 0.00525, -0.00000637};
function.setInitialGuess(guess);

SystemInterface testSystem = new SystemSrkEos(280, 1.1);
testSystem.addComponent(dataSet.getString("ComponentName"), 100.0);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.init(0);
testSystem.createDatabase(true);
testSystem.setMixingRule(2);
double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))};
double standardDeviation1[] = {0.1};
SampleValue sample =
new SampleValue(Double.parseDouble(dataSet.getString("Conductivity")),
Double.parseDouble(dataSet.getString("StandardDeviation")), sample1,
standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception e) {
logger.error("database error" + e);
}
SystemInterface testSystem = new SystemSrkEos(280, 1.1);
testSystem.addComponent(dataSet.getString("ComponentName"), 100.0);
testSystem.setPressure(Double.parseDouble(dataSet.getString("Pressure")));
testSystem.init(0);
testSystem.createDatabase(true);
testSystem.setMixingRule(2);
double sample1[] = {Double.parseDouble(dataSet.getString("Temperature"))};
double standardDeviation1[] = {0.1};
SampleValue sample = new SampleValue(Double.parseDouble(dataSet.getString("Conductivity")),
Double.parseDouble(dataSet.getString("StandardDeviation")), sample1,
standardDeviation1);
sample.setFunction(function);
sample.setThermodynamicSystem(testSystem);
sampleList.add(sample);
}
} catch (Exception ex) {
logger.error("database error" + ex);
}

double sample1[] = {0.1};
for (int i = 0; i < sampleList.size(); i++) {
logger.info("ans: " + (sampleList.get(i)).getFunction().calcValue(sample1));
}
double sample1[] = {0.1};
for (int i = 0; i < sampleList.size(); i++) {
logger.info("ans: " + (sampleList.get(i)).getFunction().calcValue(sample1));
}

SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);
SampleSet sampleSet = new SampleSet(sampleList);
optim.setSampleSet(sampleSet);

// do simulations
optim.solve();
// optim.runMonteCarloSimulation();
optim.displayResult();
optim.displayCurveFit();
}
// do simulations
optim.solve();
// optim.runMonteCarloSimulation();
optim.displayResult();
optim.displayCurveFit();
}
}
Loading