Skip to content

Commit a3a88bc

Browse files
committed
Fix indentation in QMLibraryEditor.java
The mixture of spaces and tabs was driving git crazy. In anticipation of ReactionMechanismGenerator#278 (comment) I have opted for soft tabs (4 spaces).
1 parent 0861bc7 commit a3a88bc

File tree

1 file changed

+122
-122
lines changed

1 file changed

+122
-122
lines changed

source/RMG/jing/chem/QMLibraryEditor.java

+122-122
Original file line numberDiff line numberDiff line change
@@ -48,191 +48,191 @@
4848
*/
4949

5050
public class QMLibraryEditor {
51-
52-
//data fields
51+
52+
//data fields
5353
/** The object representing the dictionary. */
5454
private static BufferedWriter dictionaryFile = null;
55-
55+
5656
/** The object representing the library */
5757
private static BufferedWriter libraryFile = null;
58-
59-
/** The newline character to use. */
60-
private static String newLine = System.getProperty("line.separator");
61-
62-
/** Number of species added to Library used for naming */
63-
//may have to get rid of this if I find naming is important
64-
private static int counter = 0;
65-
66-
//Constructor
67-
68-
//methods
69-
/** Initializes the two files Dictionary.txt and Library.txt */
70-
public static void initialize() {
71-
try {
58+
59+
/** The newline character to use. */
60+
private static String newLine = System.getProperty("line.separator");
61+
62+
/** Number of species added to Library used for naming */
63+
//may have to get rid of this if I find naming is important
64+
private static int counter = 0;
65+
66+
//Constructor
67+
68+
//methods
69+
/** Initializes the two files Dictionary.txt and Library.txt */
70+
public static void initialize() {
71+
try {
7272
// Open the log file (throws IOException if unsuccessful)
7373
dictionaryFile = new BufferedWriter(new FileWriter("QMThermoLibrary/Dictionary.txt", true));
7474
Logger.info("Creating Dictionary for QM Thermo Library");
7575
}
7676
catch (IOException e) {
7777
// This is pretty essential to new QMTP regime. Stop if it fails
78-
Logger.critical("Could not create QM Thermo Dictionary");
78+
Logger.critical("Could not create QM Thermo Dictionary");
7979
System.exit(0);
8080
}
81-
82-
try {
81+
82+
try {
8383
// Open the log file (throws IOException if unsuccessful)
84-
// Boolean Argument in FileWriter means that it will append to existing files.
84+
// Boolean Argument in FileWriter means that it will append to existing files.
8585
libraryFile = new BufferedWriter(new FileWriter("QMThermoLibrary/Library.txt", true));
8686
Logger.info("Creating Library for QM Thermo Library");
8787
}
8888
catch (IOException e) {
89-
// This is pretty essential to new QMTP regime. Stop if it fails
90-
Logger.critical("Could not create QM Thermo Library");
89+
// This is pretty essential to new QMTP regime. Stop if it fails
90+
Logger.critical("Could not create QM Thermo Library");
9191
System.exit(0);
9292
}
93-
94-
}
95-
93+
94+
}
95+
9696
/**
9797
* Close the Dictionary and Library when finished.
9898
*/
9999
public static void finish() {
100100
try {
101101
// Close the log file (throws IOException if unsuccessful)
102-
if (dictionaryFile != null) dictionaryFile.close();
102+
if (dictionaryFile != null) dictionaryFile.close();
103103
if (libraryFile != null) libraryFile.close();
104104
}
105105
catch (IOException e) {
106-
throw new RuntimeException(e);
106+
throw new RuntimeException(e);
107107
}
108108
}
109-
109+
110110
/**
111111
* Adds species to Dictionary.txt and Library.txt
112112
*/
113113
//Will probably require p_graph also
114114
//Using InChI as name as per suggestion by gmagoon
115115
public static void addQMTPThermo(ChemGraph p_graph, String inChI, ThermoData qmResult, String qmMethod, String qmProgram){
116-
//Count the number of species added for naming
117-
counter ++;
118-
//Create comment for logger. I need to double check if naming convention will interfere with model
119-
String comment = "Adding " + inChI + " to the QMTP thermo Library";
120-
// String name = "SQM(";
121-
// name.concat(Integer.toString(counter));
122-
// name.concat(")");
123-
124-
Logger.info(comment);
125-
//finish implementation of this method
126-
addLibraryEntry(inChI, qmResult, qmMethod, qmProgram);
127-
//finish implementation of this method
128-
addDictionaryEntry(inChI, p_graph);
116+
//Count the number of species added for naming
117+
counter ++;
118+
//Create comment for logger. I need to double check if naming convention will interfere with model
119+
String comment = "Adding " + inChI + " to the QMTP thermo Library";
120+
// String name = "SQM(";
121+
// name.concat(Integer.toString(counter));
122+
// name.concat(")");
123+
124+
Logger.info(comment);
125+
//finish implementation of this method
126+
addLibraryEntry(inChI, qmResult, qmMethod, qmProgram);
127+
//finish implementation of this method
128+
addDictionaryEntry(inChI, p_graph);
129129
}
130130
/**
131131
* Adds an entry to the Library of the QMTP thermo library using
132132
* the ThermData calculated from mm4 or pm3.
133133
*/
134134
public static void addLibraryEntry(String inChI, ThermoData qmResult, String qmMethod, String qmProgram) {
135-
//Assumes name in thermo library doesn't have to match the name in RMG
136-
//Not sure how true this is..figures crossed
137-
//line will be the entry to add to Library.txt using the format used in RMG thermo librarys
138-
String line = new String(inChI + " ");
139-
line = (line +Double.toString(qmResult.getH298()) + " ");
140-
line = (line +Double.toString(qmResult.getS298())+ " ");
141-
line = (line +Double.toString(qmResult.getCp300())+ " ");
142-
line = (line +Double.toString(qmResult.getCp400())+ " ");
143-
line = (line +Double.toString(qmResult.getCp500())+ " ");
144-
line = (line +Double.toString(qmResult.getCp600())+ " ");
145-
line = (line +Double.toString(qmResult.getCp800())+ " ");
146-
line = (line +Double.toString(qmResult.getCp1000())+ " ");
147-
line = (line +Double.toString(qmResult.getCp1500())+ " ");
148-
line = (line +Double.toString(qmResult.getDH())+ " ");
149-
line = (line +Double.toString(qmResult.getDS())+ " ");
150-
line = (line +Double.toString(qmResult.getDCp())+ " ");
151-
152-
//include the source of the calculation
153-
line = (line + qmProgram + " " + qmMethod + " Calculation");
154-
155-
//write to Library.txt
135+
//Assumes name in thermo library doesn't have to match the name in RMG
136+
//Not sure how true this is..figures crossed
137+
//line will be the entry to add to Library.txt using the format used in RMG thermo librarys
138+
String line = new String(inChI + " ");
139+
line = (line +Double.toString(qmResult.getH298()) + " ");
140+
line = (line +Double.toString(qmResult.getS298())+ " ");
141+
line = (line +Double.toString(qmResult.getCp300())+ " ");
142+
line = (line +Double.toString(qmResult.getCp400())+ " ");
143+
line = (line +Double.toString(qmResult.getCp500())+ " ");
144+
line = (line +Double.toString(qmResult.getCp600())+ " ");
145+
line = (line +Double.toString(qmResult.getCp800())+ " ");
146+
line = (line +Double.toString(qmResult.getCp1000())+ " ");
147+
line = (line +Double.toString(qmResult.getCp1500())+ " ");
148+
line = (line +Double.toString(qmResult.getDH())+ " ");
149+
line = (line +Double.toString(qmResult.getDS())+ " ");
150+
line = (line +Double.toString(qmResult.getDCp())+ " ");
151+
152+
//include the source of the calculation
153+
line = (line + qmProgram + " " + qmMethod + " Calculation");
154+
155+
//write to Library.txt
156156
try {
157-
libraryFile.write(line + newLine);
158-
libraryFile.flush();
157+
libraryFile.write(line + newLine);
158+
libraryFile.flush();
159159
}
160160
catch (IOException e) {
161161
// What should we do here?
162-
throw new RuntimeException(e);
162+
throw new RuntimeException(e);
163163
}
164-
164+
165165
}
166166
/**
167167
* Adds an entry to the Dictionary.txt of the QMTP thermo library using
168168
*/
169169
public static void addDictionaryEntry(String inChI, ChemGraph p_graph) {
170-
//Assumes name in thermo library doesn't have to match the name in RMG
171-
//Not sure how true this is..figures crossed
172-
//definition is a string of the name and adjacency list to be added to Dictionary.txt
173-
int i = 1;
174-
String definition = new String(inChI + newLine);
175-
//toString(i) is used as opposed to toString because that seems to give the adjacency list
176-
//without prefacing it with the chemical formula
177-
definition= (definition + p_graph.toString(i) + newLine + newLine);
178-
179-
//write to Dictionary.txt
170+
//Assumes name in thermo library doesn't have to match the name in RMG
171+
//Not sure how true this is..figures crossed
172+
//definition is a string of the name and adjacency list to be added to Dictionary.txt
173+
int i = 1;
174+
String definition = new String(inChI + newLine);
175+
//toString(i) is used as opposed to toString because that seems to give the adjacency list
176+
//without prefacing it with the chemical formula
177+
definition= (definition + p_graph.toString(i) + newLine + newLine);
178+
179+
//write to Dictionary.txt
180180
try {
181-
dictionaryFile.write(definition);
182-
dictionaryFile.flush();
181+
dictionaryFile.write(definition);
182+
dictionaryFile.flush();
183183
}
184184
catch (IOException e) {
185185
// What should we do here?
186-
throw new RuntimeException(e);
186+
throw new RuntimeException(e);
187187
}
188188
}
189-
189+
190190
/**
191191
* Adds an entry to the Dictionary.txt of the QMTP thermo library using
192192
* @throws IOException
193193
194194
*/
195195
public static HashMap readLibrary(String p_qmThermoFileName) throws IOException {
196-
try {
197-
FileReader in = new FileReader(p_qmThermoFileName);
198-
BufferedReader data = new BufferedReader(in);
199-
String line = ChemParser.readMeaningfulLine(data, true);
200-
HashMap <String, ThermoData> library = new HashMap<String, ThermoData>();
201-
while (line!=null){
202-
String [] result = line.split("\\s");
203-
204-
// Construct information to create instance of ThermData
205-
String inChI = result[0];
206-
String thermo = result[1];
207-
208-
for(int i=2; i<13; i++){
209-
thermo = thermo + " " + result[i];
210-
}
211-
212-
int listLength = result.length;
213-
String comments = result[13];
214-
//check this upper bound might need to be listLength + 1 -nyee
215-
for(int i=14; i < listLength; i++){
216-
comments = comments + " " + result[i];
217-
}
218-
219-
//Parse out thermoData, and include name and comments
220-
ThermoData thermoData = ChemParser.parseThermoFromLibrary(thermo);
221-
ThermoData newThermoData = new ThermoData(inChI, thermoData, comments);
222-
223-
library.put(inChI, newThermoData);
224-
line = ChemParser.readMeaningfulLine(data, true);
225-
}
226-
227-
in.close();
228-
return library;
229-
230-
}
231-
232-
catch(IOException e) {
233-
Logger.logStackTrace(e);
234-
throw new IOException("Can't read thermo in primary thermo library!");
235-
}
236-
196+
try {
197+
FileReader in = new FileReader(p_qmThermoFileName);
198+
BufferedReader data = new BufferedReader(in);
199+
String line = ChemParser.readMeaningfulLine(data, true);
200+
HashMap <String, ThermoData> library = new HashMap<String, ThermoData>();
201+
while (line!=null){
202+
String [] result = line.split("\\s");
203+
204+
// Construct information to create instance of ThermData
205+
String inChI = result[0];
206+
String thermo = result[1];
207+
208+
for(int i=2; i<13; i++){
209+
thermo = thermo + " " + result[i];
210+
}
211+
212+
int listLength = result.length;
213+
String comments = result[13];
214+
//check this upper bound might need to be listLength + 1 -nyee
215+
for(int i=14; i < listLength; i++){
216+
comments = comments + " " + result[i];
217+
}
218+
219+
//Parse out thermoData, and include name and comments
220+
ThermoData thermoData = ChemParser.parseThermoFromLibrary(thermo);
221+
ThermoData newThermoData = new ThermoData(inChI, thermoData, comments);
222+
223+
library.put(inChI, newThermoData);
224+
line = ChemParser.readMeaningfulLine(data, true);
225+
}
226+
227+
in.close();
228+
return library;
229+
230+
}
231+
232+
catch(IOException e) {
233+
Logger.logStackTrace(e);
234+
throw new IOException("Can't read thermo in primary thermo library!");
235+
}
236+
237237
}
238238
}

0 commit comments

Comments
 (0)