Skip to content

Commit

Permalink
1. Added active material categories
Browse files Browse the repository at this point in the history
2. Added theoretical capacity (incl. a small calculation tool in the
"Add" and "Edit" panes) of the cells in literature of which the fade
rates are taken from.
--> this should give a better overview at which scale the parameters are
determined (especially if compared to upscaled systems in future)
  • Loading branch information
d.emmel authored and d.emmel committed Aug 12, 2023
1 parent 915e531 commit c9b45e0
Show file tree
Hide file tree
Showing 24 changed files with 1,336 additions and 800 deletions.
6 changes: 6 additions & 0 deletions src/main/java/de/dominikemmel/reflowlab/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private static void initialise(String table) throws SQLException {
+ "Abbreviation VARCHAR(255),"
+ "Name VARCHAR(255),"
+ "StructuralFormula VARCHAR(255),"
+ "Category VARCHAR(255),"
+ "M FLOAT,"
+ "n INT,"
+ "RefIDn INT,"
Expand Down Expand Up @@ -273,6 +274,11 @@ private static void initialise(String table) throws SQLException {
+ "degRate FLOAT,"
+ "RefIDdegRate INT,"
+ "f FLOAT,"
+ "fEloVol FLOAT,"
+ "fConc FLOAT,"
+ "note VARCHAR(1000),"
+ "fSymCellCycl INT,"
+ "theoMaxCap FLOAT,"
+ "RefIDf INT,"
+ "editDate TIMESTAMP,"
+ "primary key(ID));";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/dominikemmel/reflowlab/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class MainApp extends Application {

@Override
public void start(Stage primaryStage) throws IOException {

Updates.updateDB();

Parent root = FXMLLoader.load(getClass().getResource("/de/dominikemmel/reflowlab/controller/maincontrol/fxml/main.fxml"));

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/de/dominikemmel/reflowlab/Updates.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.dominikemmel.reflowlab;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Updates {

public static void updateDB() {


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class ActiveMaterialsController implements javafx.fxml.Initializable {
@FXML private TableColumn<ObjActiveMaterial, Double> PH;
@FXML private TableColumn<ObjActiveMaterial, Double> E;
@FXML private TableColumn<ObjActiveMaterial, String> EDITDATE;
@FXML private TableColumn<ObjActiveMaterial, String> Category;

@FXML private TableColumn<ObjActiveMaterial, Integer> RefIDn;
@FXML private TableColumn<ObjActiveMaterial, Integer> RefIDNumberH;
Expand All @@ -69,6 +70,7 @@ public class ActiveMaterialsController implements javafx.fxml.Initializable {
@FXML private TextFlow SaltC_TextFlow;
@FXML private TextFlow PH_TextFlow;
@FXML private TextFlow E_TextFlow;
@FXML private TextFlow Category_TextFlow;
@FXML private TextFlow EDITDATE_TextFlow;

@FXML private Button addActiveMaterial;
Expand Down Expand Up @@ -110,6 +112,7 @@ public void reloadDataActiveMaterials() {
objActiveMaterial.SaltC.set(res.getDouble("SaltC"));
objActiveMaterial.PH.set(res.getDouble("PH"));
objActiveMaterial.E.set(res.getDouble("E"));
objActiveMaterial.Category.set(res.getString("Category"));
objActiveMaterial.RefIDn.set(res.getInt("RefIDn"));
objActiveMaterial.RefIDNumberH.set(res.getInt("RefIDNumberH"));
objActiveMaterial.RefIDCAM.set(res.getInt("RefIDCAM"));
Expand Down Expand Up @@ -137,6 +140,7 @@ public void reloadDataActiveMaterials() {
SaltC.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, Double>("SaltC"));
PH.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, Double>("PH"));
E.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, Double>("E"));
Category.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, String>("Category"));
EDITDATE.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, String>("EDITDATE"));
RefIDn.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, Integer>("RefIDn"));
RefIDNumberH.setCellValueFactory(new PropertyValueFactory<ObjActiveMaterial, Integer>("RefIDNumberH"));
Expand Down Expand Up @@ -288,11 +292,17 @@ private void addColumnNames() {
Text E1 = new Text("E");
E1.setStyle("-fx-font-weight: bold");
E1.setStyle("-fx-font-style: italic");
Text E2 = new Text(" vs NHE / V");
Text E2 = new Text(" vs NHE / V");
E2.setStyle("-fx-font-weight: bold");

E_TextFlow.getChildren().addAll(E1,E2);

//Category:
Text Category1 = new Text("Category");
Category1.setStyle("-fx-font-weight: bold");

Category_TextFlow.getChildren().addAll(Category1);

//EDITDATE:
Text EDITDATE1 = new Text("Date");
EDITDATE1.setStyle("-fx-font-weight: bold");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class AddActiveMaterialController implements javafx.fxml.Initializable {
@FXML private TextField inputName;
@FXML private TextField inputSTRUCTURALFORMULA;
@FXML private TextField inputM;
@FXML private TextField inputCategory;
@FXML private TextField inputN;
@FXML private TextField inputNumberH;
@FXML private TextField inputCAM;
Expand Down Expand Up @@ -205,6 +206,7 @@ public void btnAddActiveMaterial(ActionEvent event) throws ClassNotFoundExceptio
String inputName_Value = VariousMethods.getTextFieldInput(inputName, "stringInput");
String inputSTRUCTURALFORMULA_Value = VariousMethods.getTextFieldInput(inputSTRUCTURALFORMULA, "stringInput");
Double inputM_Value = VariousMethods.getTextFieldInput(inputM, "doubleInput");
String inputCategory_Value = VariousMethods.getTextFieldInput(inputCategory, "stringInput");
Integer inputN_Value = VariousMethods.getTextFieldInput(inputN, "integerInput");
Integer inputNumberH_Value = VariousMethods.getTextFieldInput(inputNumberH, "integerInput");
Double inputCAM_Value = VariousMethods.getTextFieldInput(inputCAM, "doubleInput");
Expand All @@ -222,6 +224,7 @@ public void btnAddActiveMaterial(ActionEvent event) throws ClassNotFoundExceptio
objActiveMaterial.NAME.set(inputName_Value);
objActiveMaterial.STRUCTURALFORMULA.set(inputSTRUCTURALFORMULA_Value);
objActiveMaterial.M.set(inputM_Value);
objActiveMaterial.Category.set(inputCategory_Value);
objActiveMaterial.N.set(inputN_Value);
objActiveMaterial.NumberH.set(inputNumberH_Value);
objActiveMaterial.CAM.set(inputCAM_Value);
Expand All @@ -234,10 +237,10 @@ public void btnAddActiveMaterial(ActionEvent event) throws ClassNotFoundExceptio
try {
Connection con = Database.getConnection("activeMaterial");
Statement state = con.createStatement();
state.executeUpdate("INSERT INTO activeMaterial(ID, Abbreviation, Name, StructuralFormula, M, n, NumberH, CAM, Solvent, Salt, Saltc, pH, E, editDate)"
state.executeUpdate("INSERT INTO activeMaterial(ID, Abbreviation, Name, StructuralFormula, M, Category, n, NumberH, CAM, Solvent, Salt, Saltc, pH, E, editDate)"
+" VALUES(DEFAULT, '"+objActiveMaterial.ABBREVIATION.getValue()+"', '"
+objActiveMaterial.NAME.getValue()+"', '"+objActiveMaterial.STRUCTURALFORMULA.getValue()+"', "
+objActiveMaterial.M.getValue()+", "+objActiveMaterial.N.getValue()+", "+objActiveMaterial.NumberH.getValue()+", "
+objActiveMaterial.M.getValue()+", '"+objActiveMaterial.Category.getValue()+"', "+objActiveMaterial.N.getValue()+", "+objActiveMaterial.NumberH.getValue()+", "
+objActiveMaterial.CAM.getValue()+", '"+objActiveMaterial.SOLVENT.getValue()+"', '"
+objActiveMaterial.Salt.getValue()+"', "
+objActiveMaterial.SaltC.getValue()+", "+objActiveMaterial.PH.getValue()+", "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class EditActiveMaterialController implements javafx.fxml.Initializable
@FXML private TextField inputName;
@FXML private TextField inputSTRUCTURALFORMULA;
@FXML private TextField inputM;
@FXML private TextField inputCategory;
@FXML private TextField inputN;
@FXML private TextField inputNumberH;
@FXML private TextField inputCAM;
Expand Down Expand Up @@ -67,6 +68,7 @@ public void setSelectionData(ObservableList<ObjActiveMaterial> selection) throws
inputName.setText(selection.get(0).NAME.getValue());
inputSTRUCTURALFORMULA.setText(selection.get(0).STRUCTURALFORMULA.getValue());
inputM.setText(selection.get(0).M.getValue().toString());
inputCategory.setText(selection.get(0).Category.getValue());
inputN.setText(selection.get(0).N.getValue().toString());
inputNumberH.setText(selection.get(0).NumberH.getValue().toString());
inputCAM.setText(selection.get(0).CAM.getValue().toString());
Expand Down Expand Up @@ -238,6 +240,7 @@ public void btnEditActiveMaterial(ActionEvent event) throws ClassNotFoundExcepti
String inputName_Value = VariousMethods.getTextFieldInput(inputName, "stringInput");
String inputSTRUCTURALFORMULA_Value = VariousMethods.getTextFieldInput(inputSTRUCTURALFORMULA, "stringInput");
Double inputM_Value = VariousMethods.getTextFieldInput(inputM, "doubleInput");
String inputCategory_Value = VariousMethods.getTextFieldInput(inputCategory, "stringInput");
Integer inputN_Value = VariousMethods.getTextFieldInput(inputN, "integerInput");
Integer inputNumberH_Value = VariousMethods.getTextFieldInput(inputNumberH, "integerInput");
Double inputCAM_Value = VariousMethods.getTextFieldInput(inputCAM, "doubleInput");
Expand All @@ -251,6 +254,7 @@ public void btnEditActiveMaterial(ActionEvent event) throws ClassNotFoundExcepti
objActiveMaterial.NAME.set(inputName_Value);
objActiveMaterial.STRUCTURALFORMULA.set(inputSTRUCTURALFORMULA_Value);
objActiveMaterial.M.set(inputM_Value);
objActiveMaterial.Category.set(inputCategory_Value);
objActiveMaterial.N.set(inputN_Value);
objActiveMaterial.NumberH.set(inputNumberH_Value);
objActiveMaterial.CAM.set(inputCAM_Value);
Expand All @@ -266,8 +270,8 @@ public void btnEditActiveMaterial(ActionEvent event) throws ClassNotFoundExcepti
state.executeUpdate("UPDATE activeMaterial "
+ "SET ID = "+selection.get(0).ID.getValue()+
", Abbreviation = '"+objActiveMaterial.ABBREVIATION.getValue()+"', Name = '"+objActiveMaterial.NAME.getValue()+
"', StructuralFormula = '"+objActiveMaterial.STRUCTURALFORMULA.getValue()+"', M = "+objActiveMaterial.M.getValue()+
", n = "+objActiveMaterial.N.getValue()+", NumberH = "+objActiveMaterial.NumberH.getValue()+
"', StructuralFormula = '"+objActiveMaterial.STRUCTURALFORMULA.getValue()+"', M = "+objActiveMaterial.M.getValue()+ ", Category = '"+objActiveMaterial.Category.getValue()+
"', n = "+objActiveMaterial.N.getValue()+", NumberH = "+objActiveMaterial.NumberH.getValue()+
", CAM = "+objActiveMaterial.CAM.getValue()+", Solvent = '"+objActiveMaterial.SOLVENT.getValue()+
"', Salt = '"+objActiveMaterial.Salt.getValue()+
"', Saltc = "+objActiveMaterial.SaltC.getValue()+", pH = "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ObjActiveMaterial {
public DoubleProperty SaltC = new SimpleDoubleProperty();
public DoubleProperty PH = new SimpleDoubleProperty();
public DoubleProperty E = new SimpleDoubleProperty();
public StringProperty Category = new SimpleStringProperty();
public StringProperty EDITDATE = new SimpleStringProperty();
public IntegerProperty RefIDn = new SimpleIntegerProperty();
public IntegerProperty RefIDNumberH = new SimpleIntegerProperty();
Expand Down Expand Up @@ -67,6 +68,9 @@ public DoubleProperty PHProperty() {
public DoubleProperty EProperty() {
return E;
}
public StringProperty CategoryProperty() {
return Category;
}
public StringProperty EDITDATEProperty() {
return EDITDATE;
}
Expand All @@ -84,7 +88,7 @@ public IntegerProperty RefIDEProperty() {
}

// Using constructor to set values of properties.
public ObjActiveMaterial(int IDValue, String ABBREVIATIONValue, String NAMEValue, String STRUCTURALFORMULAValue, double MValue, int NValue, int NumberHValue, double CAMValue, String SOLVENTValue, String SaltValue, double SaltCValue, double PHValue, double EValue, String EDITDATEValue, int RefIDnValue, int RefIDNumberHValue, int RefIDCAMValue, int RefIDEValue) {
public ObjActiveMaterial(int IDValue, String ABBREVIATIONValue, String NAMEValue, String STRUCTURALFORMULAValue, double MValue, int NValue, int NumberHValue, double CAMValue, String SOLVENTValue, String SaltValue, double SaltCValue, double PHValue, double EValue, String CategoryValue, String EDITDATEValue, int RefIDnValue, int RefIDNumberHValue, int RefIDCAMValue, int RefIDEValue) {
ID.set(IDValue);
ABBREVIATION.set(ABBREVIATIONValue);
NAME.set(NAMEValue);
Expand All @@ -98,6 +102,7 @@ public ObjActiveMaterial(int IDValue, String ABBREVIATIONValue, String NAMEValue
SaltC.set(SaltCValue);
PH.set(PHValue);
E.set(EValue);
Category.set(CategoryValue);
EDITDATE.set(EDITDATEValue);
RefIDn.set(RefIDnValue);
RefIDNumberH.set(RefIDNumberHValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@

import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;

import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import de.dominikemmel.reflowlab.Database;
import de.dominikemmel.reflowlab.MyConstants;
import de.dominikemmel.reflowlab.VariousMethods;
import de.dominikemmel.reflowlab.controller.costanalysistool.CostAnalysisToolController;
import de.dominikemmel.reflowlab.controller.references.ObjReference;
import de.dominikemmel.reflowlab.controller.references.ReferencesController;

Expand Down Expand Up @@ -51,6 +57,16 @@ public class AddElectrolytesController implements javafx.fxml.Initializable {
private TextField inputdegRate;
@FXML
private TextField inputf;
@FXML
private TextField inputTheoMaxCap;
@FXML
private TextField inputNote;
@FXML
private TextField inputfEloVol;
@FXML
private TextField inputfConc;
@FXML
private CheckBox inputfSymCellCycl;

@FXML
private TextField inputRefDOIMaxSolubility;
Expand Down Expand Up @@ -108,6 +124,9 @@ public class AddElectrolytesController implements javafx.fxml.Initializable {
@FXML
private Button btnInputRefF;

@FXML
private Button btnCalcQmax;

String table = "electrolyte";

@Override
Expand Down Expand Up @@ -415,6 +434,48 @@ public void btnInputRefdegRateEvent(ActionEvent event) {
inputRefF.setText(inputRefdegRate.getText());
}

@FXML
public void btnCalcQmaxEvent(ActionEvent event) {

double vol = Double.valueOf(inputfEloVol.getText()) * Math.pow(10, -3);
double conc = Double.valueOf(inputfConc.getText());

int numberEl = 0;

try {

ResultSet res = Database.selectData("activeMaterial");

ObservableList<Integer> dataActiveMaterial = FXCollections.observableArrayList();

while (res.next()) {
String sqlAbbrev = res.getString("ABBREVIATION");

if (sqlAbbrev.equals(inputActiveMaterial.getText())) {
int dataNumberEl = res.getInt("N");
dataActiveMaterial.add(dataNumberEl);
}
}

if (!dataActiveMaterial.isEmpty()) {
numberEl = dataActiveMaterial.get(0).intValue();
}


} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}

// theo. max. capacity / mAh
double maxCap = 0;
if (numberEl > 0) {
maxCap = MyConstants.F * vol * conc * numberEl * Math.pow(10, 3) / (60 * 60);
}

inputTheoMaxCap.setText(String.valueOf(maxCap));
}


// Event Listener on Button.onAction
@FXML
public void cancelAddElectrolytes(ActionEvent event) {
Expand All @@ -441,6 +502,11 @@ public void addAddElectrolytes(ActionEvent event) throws ClassNotFoundException,
Double inputAlphaRed_Value = VariousMethods.getTextFieldInput(inputAlphaRed, "doubleInput");
Double inputdegRate_Value = VariousMethods.getTextFieldInput(inputdegRate, "doubleInput");
Double inputf_Value = VariousMethods.getTextFieldInput(inputf, "doubleInput");
Double inputTheoMaxCap_Value = VariousMethods.getTextFieldInput(inputTheoMaxCap, "doubleInput");
String inputNote_Value = VariousMethods.getTextFieldInput(inputNote, "stringInput");
Double inputfEloVol_Value = VariousMethods.getTextFieldInput(inputfEloVol, "doubleInput");
Double inputfConc_Value = VariousMethods.getTextFieldInput(inputfConc, "doubleInput");
Boolean inputfSymCellCycl_Value = inputfSymCellCycl.isSelected();

objElectrolytes.ActiveMaterial.set(inputActiveMaterial_Value);
objElectrolytes.Solvent.set(inputSolvent_Value);
Expand All @@ -456,18 +522,30 @@ public void addAddElectrolytes(ActionEvent event) throws ClassNotFoundException,
objElectrolytes.AlphaRed.set(inputAlphaRed_Value);
objElectrolytes.degRate.set(inputdegRate_Value);
objElectrolytes.f.set(inputf_Value);
objElectrolytes.theoMaxCap.set(inputTheoMaxCap_Value);
objElectrolytes.note.set(inputNote_Value);
objElectrolytes.fEloVol.set(inputfEloVol_Value);
objElectrolytes.fConc.set(inputfConc_Value);
objElectrolytes.fSymCellCycl.set(inputfSymCellCycl_Value);

double fSymCellCycl_sql = 0;
if (inputfSymCellCycl_Value) {
fSymCellCycl_sql = 1;
} else {
fSymCellCycl_sql = 0;
}

try {
Connection con = Database.getConnection("electrolyte");
Statement state = con.createStatement();
state.executeUpdate("INSERT INTO electrolyte(ID, ActiveMaterial, Solvent, Salt, cSalt, pH, maxSolubility, DOx, DRed, kOx, AlphaOx, kRed, AlphaRed, degRate, f, editDate)"
state.executeUpdate("INSERT INTO electrolyte(ID, ActiveMaterial, Solvent, Salt, cSalt, pH, maxSolubility, DOx, DRed, kOx, AlphaOx, kRed, AlphaRed, degRate, f, theoMaxCap, fEloVol, fConc, note, fSymCellCycl, editDate)"
+" VALUES(DEFAULT, '"+objElectrolytes.ActiveMaterial.getValue()+"', '"
+objElectrolytes.Solvent.getValue()+"', '"+objElectrolytes.Salt.getValue()+"', "
+objElectrolytes.cSalt.getValue()+", "
+objElectrolytes.pH.getValue()+", "+objElectrolytes.maxSolubility.getValue()+", "
+objElectrolytes.DOx.getValue()+", "+objElectrolytes.DRed.getValue()+", "+objElectrolytes.kOx.getValue()+", "
+objElectrolytes.AlphaOx.getValue()+", "+objElectrolytes.kRed.getValue()+", "+objElectrolytes.AlphaRed.getValue()+", "
+objElectrolytes.degRate.getValue()+", "+objElectrolytes.f.getValue()+", CURRENT_TIMESTAMP)");
+objElectrolytes.degRate.getValue()+", "+objElectrolytes.f.getValue()+", "+objElectrolytes.theoMaxCap.getValue()+", "+objElectrolytes.fEloVol.getValue()+", "+objElectrolytes.fConc.getValue()+", '"+objElectrolytes.note.getValue()+"', "+fSymCellCycl_sql+", CURRENT_TIMESTAMP)");

} catch (ClassNotFoundException e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit c9b45e0

Please sign in to comment.