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: cleanup warnings #404

Merged
merged 3 commits into from
May 3, 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 @@ -83,8 +83,7 @@ public void setYvalues(double[] y, String name, String unit) {
@SuppressWarnings("deprecation")
public void createFile() {
try {
NetcdfFileWriter ncfile =
NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fileName, null);
ncfile = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fileName, null);
} catch (IOException e) {
System.err.println("ERROR creating file");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,78 +18,77 @@
* @version $Id: $Id
*/
public class DataReader implements DataReaderInterface {
protected String fileName;
protected ArrayList<DataObject> sampleObjectList = new ArrayList<DataObject>();
protected String fileName;
protected ArrayList<DataObject> sampleObjectList = new ArrayList<DataObject>();

/**
* <p>
* Constructor for DataReader.
* </p>
*/
public DataReader() {}
/**
* <p>
* Constructor for DataReader.
* </p>
*/
public DataReader() {}

/**
* <p>
* Constructor for DataReader.
* </p>
*
* @param fileName a {@link java.lang.String} object
*/
public DataReader(String fileName) {
this.fileName = fileName;
readData();
}
/**
* <p>
* Constructor for DataReader.
* </p>
*
* @param fileName a {@link java.lang.String} object
*/
public DataReader(String fileName) {
this.fileName = fileName;
readData();
}

/** {@inheritDoc} */
@Override
public void readData() {
StringTokenizer tokenizer;
String token;
/** {@inheritDoc} */
@Override
public void readData() {
StringTokenizer tokenizer;

String path = "c:/logdata/" + this.fileName + ".log";
System.out.println(path);
String path = "c:/logdata/" + this.fileName + ".log";
System.out.println(path);

try (RandomAccessFile file = new RandomAccessFile(path, "r")) {
long filepointer = 0;
long length = file.length();
for (int i = 0; i < 6; i++) {
file.readLine();
}
do {
System.out.println("test");
String s = file.readLine();
tokenizer = new StringTokenizer(s);
token = tokenizer.nextToken();
try (RandomAccessFile file = new RandomAccessFile(path, "r")) {
long filepointer = 0;
long length = file.length();
for (int i = 0; i < 6; i++) {
file.readLine();
}
do {
System.out.println("test");
String s = file.readLine();
tokenizer = new StringTokenizer(s);
tokenizer.nextToken();

filepointer = file.getFilePointer();
tokenizer.nextToken();
} while (filepointer < length);
} catch (Exception e) {
String err = e.toString();
System.out.println(err);
}
filepointer = file.getFilePointer();
tokenizer.nextToken();
} while (filepointer < length);
} catch (Exception e) {
String err = e.toString();
System.out.println(err);
}
}

/**
* <p>
* Getter for the field <code>sampleObjectList</code>.
* </p>
*
* @return a {@link java.util.ArrayList} of {@link DataObject}
*/
public ArrayList<DataObject> getSampleObjectList() {
return sampleObjectList;
}
/**
* <p>
* Getter for the field <code>sampleObjectList</code>.
* </p>
*
* @return a {@link java.util.ArrayList} of {@link DataObject}
*/
public ArrayList<DataObject> getSampleObjectList() {
return sampleObjectList;
}

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
DataReader reader = new DataReader("31011222");
}
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
DataReader reader = new DataReader("31011222");
}
}
59 changes: 34 additions & 25 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,17 @@ public void addSalt(String componentName, double value) {
@Override
public void addTBPfraction(String componentName, double numberOfMoles, double molarMass,
double density) {
if (density < 0.0 || molarMass < 0.0) {
String msg = "Negative input molar mass or density.";
if (density < 0.0) {
String msg = "Negative input density.";
logger.error(msg);
neqsim.util.exception.InvalidInputException e =
new neqsim.util.exception.InvalidInputException(msg);
throw new RuntimeException(e);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "density", "is negative."));
}
if (molarMass < 0.0) {
String msg = "Negative input molar mass.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "molarMass", "is negative."));
}

SystemInterface refSystem = null;
Expand Down Expand Up @@ -886,11 +891,17 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo
public void addTBPfraction(String componentName, double numberOfMoles, double molarMass,
double density, double criticalTemperature, double criticalPressure, double acentricFactor) {
if (density < 0.0 || molarMass < 0.0) {
String msg = "Negative input molar mass or density.";
String msg = "Negative input density.";
logger.error(msg);
neqsim.util.exception.InvalidInputException e =
new neqsim.util.exception.InvalidInputException(msg);
throw new RuntimeException(e);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "density", "is negative."));
}

if (density < 0.0 || molarMass < 0.0) {
String msg = "Negative input molar mass.";
logger.error(msg);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"addTBPfraction", "molarMass", "is negative."));
}

SystemInterface refSystem = null;
Expand Down Expand Up @@ -1099,9 +1110,8 @@ public void addComponent(String componentName, double moles) {
if (moles < 0.0) {
String msg = "Negative input number of moles of component: " + componentName;
logger.error(msg);
neqsim.util.exception.InvalidInputException e =
new neqsim.util.exception.InvalidInputException(msg);
throw new RuntimeException(e);
throw new RuntimeException(
new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg));
}
setTotalNumberOfMoles(getTotalNumberOfMoles() + moles);
// System.out.println("adding " + componentName);
Expand Down Expand Up @@ -1211,7 +1221,7 @@ public void addComponent(String componentName, double moles, int phaseNumber) {
String msg = "Negative input number of moles.";
logger.error(msg);
neqsim.util.exception.InvalidInputException e =
new neqsim.util.exception.InvalidInputException(msg);
new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg);
throw new RuntimeException(e);
}

Expand Down Expand Up @@ -1737,8 +1747,7 @@ public void initAnalytic(int type) {
}
}
numberOfPhases = 2;
}
else if (type == 1) {
} else if (type == 1) {
for (int i = 0; i < numberOfPhases; i++) {
if (IsPhase(i)) {
getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 1, phaseType[phaseIndex[i]],
Expand Down Expand Up @@ -3813,18 +3822,19 @@ public java.lang.String getFluidName() {
public void setFluidName(java.lang.String fluidName) {
this.fluidName = fluidName;
}

public void addToComponentNames(java.lang.String name) {
for(int j=0;j<componentNames.size();j++) {
componentNames.set(j, componentNames.get(j)+name);
for (int j = 0; j < componentNames.size(); j++) {
componentNames.set(j, componentNames.get(j) + name);
}
for (int i = 0; i < getMaxNumberOfPhases(); i++) {
for(int j=0;j<componentNames.size();j++) {
getPhase(i).getComponent(j).setComponentName(getPhase(i).getComponent(j).getComponentName()+name);
for (int j = 0; j < componentNames.size(); j++) {
getPhase(i).getComponent(j)
.setComponentName(getPhase(i).getComponent(j).getComponentName() + name);
}
}
}

/**
* <p>
* setLastTBPasPlus.
Expand Down Expand Up @@ -5083,11 +5093,10 @@ public SystemProperties getProperties() {
private void setMolarComposition(double[] molefractions, String type) {
double totalFlow = getTotalNumberOfMoles();
if (totalFlow < 1e-100) {
String msg = "Total flow can not be 0 when setting molar composition";
String msg = "must be larger than 0 (1e-100) when setting molar composition";
logger.error(msg);
neqsim.util.exception.InvalidInputException e =
new neqsim.util.exception.InvalidInputException(msg);
throw new RuntimeException(e);
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this,
"setMolarComposition", "totalFlow", msg));
}
double sum = 0;
for (double value : molefractions) {
Expand Down
Loading