Skip to content

Commit 469717b

Browse files
committed
minor fixes and optimizations
1 parent eb2ec51 commit 469717b

File tree

9 files changed

+116
-106
lines changed

9 files changed

+116
-106
lines changed

.idea/workspace.xml

Lines changed: 70 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sindri/Controllers/PureSubstanceController.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ def genDiagrams(self):
167167
try:
168168
if self.diagramsView.le_isotherms.text().strip() != "":
169169
self.isotherms_range = [
170-
float(i) for i in self.diagramsView.le_isotherms.text().replace(',', ' ').split()
171-
170+
float(i)
171+
for i in self.diagramsView.le_isotherms.text()
172+
.replace(",", " ")
173+
.split()
172174
]
173175
else:
174176
self.isotherms_range = []
@@ -231,7 +233,7 @@ def plotDiagrams(self):
231233
lnscale=self.diagramsView.checkBox_logscale.isChecked(),
232234
grid=self.diagramsView.checkBox_grid.isChecked(),
233235
smooth=self.diagramsView.checkBox_smooth.isChecked(),
234-
plotisothermals=self.diagramsView.checkBox_isotherms.isChecked()
236+
plotisothermals=self.diagramsView.checkBox_isotherms.isChecked(),
235237
)
236238
elif choice == "TS":
237239
self.diag.plotTS(

Sindri/Models/LiquidModel.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
2-
from fortran.UNIFAC import getgamma as _helper_getGamma2
2+
3+
# from fortran.UNIFAC import getgamma as _helper_getGamma2
34

45
import db
56

@@ -95,13 +96,13 @@ def __init__(self, subs_ids):
9596
# cursor.close()
9697

9798
def getGamma(self, x, T: float):
98-
return _helper_getGamma2(
99-
x, T,self.amk, self.vk, self.Rk, self.Qk
100-
)
101-
# x = np.atleast_1d(x)
102-
# return _helper_getGamma(
103-
# x, T, self.amk, self.vk, self.Rk, self.Qk
99+
# return _helper_getGamma2(
100+
# x, T,self.amk, self.vk, self.Rk, self.Qk
104101
# )
102+
# x = np.atleast_1d(x)
103+
return _helper_getGamma(
104+
x, T, self.n, self.m, self.amk, self.vk, self.Rk, self.Qk
105+
)
105106

106107

107108
from numba import njit

Sindri/Views/AddAliasView.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def __init__(self, controller, parent=None):
1414

1515
self.btn_ok.clicked.connect(self.ok_clicked)
1616
self.btn_cancel.clicked.connect(self.cancel_clicked)
17-
1817

1918
def ok_clicked(self):
2019
self.controller.ok_clicked()

Sindri/Views/PureSubstanceDiagramsView.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66

77
class PureSubstanceDiagramsView(QtWidgets.QWidget, Ui_Form_PureSubstanceDiagrams):
8-
def __init__(
9-
self,
10-
controller,
11-
model: PureSubstanceModel,
12-
parent=None,
13-
):
8+
def __init__(self, controller, model: PureSubstanceModel, parent=None):
149
super().__init__(parent)
1510
self.setupUi(self)
1611

Sindri/db_addSubstanceProperties.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def __init__(self, parent=None):
8888
QtGui.QPixmap(":/images/antoine_correlation_equation.png")
8989
)
9090

91-
self.tableWidget_aliases.horizontalHeader().setDefaultAlignment(QtCore.Qt.AlignLeft)
91+
self.tableWidget_aliases.horizontalHeader().setDefaultAlignment(
92+
QtCore.Qt.AlignLeft
93+
)
9294

9395
def confirm_clicked(self):
9496

Sindri/db_editSubstanceProperties.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def __init__(self, parent=None, hl_row=None):
224224
)
225225

226226
# alias
227-
self.tableWidget_aliases.horizontalHeader().setDefaultAlignment(QtCore.Qt.AlignLeft)
227+
self.tableWidget_aliases.horizontalHeader().setDefaultAlignment(
228+
QtCore.Qt.AlignLeft
229+
)
228230
self.btn_add_alias.clicked.connect(self.addAlias)
229231
self.btn_remove_alias.clicked.connect(self.removeAlias)
230232
self.loadAliases()

Sindri/diagrams.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
"S": "Entropy",
2323
}
2424

25+
2526
class IsothermalPVStruct:
26-
def __init__(self, T: List[float], V:List[float],P:List[List[float]]):
27+
def __init__(self, T: List[float], V: List[float], P: List[List[float]]):
2728
self.T = T
2829
self.V = V
2930
self.P = P
@@ -49,7 +50,7 @@ def __init__(
4950
self.compound = compound
5051
self.eosname = eosname
5152
self.eoseq = eoseq
52-
self.isotherms :IsothermalPVStruct = isotherms
53+
self.isotherms: IsothermalPVStruct = isotherms
5354

5455
self.Tliq, self.Tvap = np.zeros(self.n), np.zeros(self.n)
5556
self.Pliq, self.Pvap = np.zeros(self.n), np.zeros(self.n)
@@ -70,7 +71,7 @@ def __init__(
7071
self.lnscale = False
7172
self.grid = True
7273
self.smooth = True
73-
self.plotisotherms= False
74+
self.plotisotherms = False
7475

7576
for i in range(self.n):
7677
self.Tliq[i], self.Tvap[i] = self.propsliq[i].T, self.propsvap[i].T
@@ -102,8 +103,15 @@ def __init__(
102103
else:
103104
self.has_isotherms = False
104105

105-
106-
def plotPV(self, xunit: str, yunit: str, lnscale=True, smooth=True, grid=True, plotisothermals=False):
106+
def plotPV(
107+
self,
108+
xunit: str,
109+
yunit: str,
110+
lnscale=True,
111+
smooth=True,
112+
grid=True,
113+
plotisothermals=False,
114+
):
107115
self.x_letter, self.y_letter = "V", "P"
108116
self.xliq, self.yliq = self.Vliq, self.Pliq
109117
self.xvap, self.yvap = self.Vvap, self.Pvap
@@ -245,16 +253,22 @@ def _plot(self):
245253

246254
try:
247255
if self.plotisotherms and self.has_isotherms:
248-
v = conv_unit(np.atleast_1d(self.isotherms.V), SI_dict[self.x_letter], self.xunit)
256+
v = conv_unit(
257+
np.atleast_1d(self.isotherms.V), SI_dict[self.x_letter], self.xunit
258+
)
249259
if self.lnscale:
250260
v = np.log(v)
251261
for i in range(len(self.isotherms.T)):
252262
t = self.isotherms.T[i]
253-
p = conv_unit(np.atleast_1d(self.isotherms.P[i]), SI_dict[self.y_letter], self.yunit)
263+
p = conv_unit(
264+
np.atleast_1d(self.isotherms.P[i]),
265+
SI_dict[self.y_letter],
266+
self.yunit,
267+
)
254268
if self.lnscale:
255269
p = np.log(p)
256270
label = "isothermal at {:.3f} K".format(t)
257-
ax.plot(v, p, label=label, linestyle='--')
271+
ax.plot(v, p, label=label, linestyle="--")
258272
except Exception as e:
259273
print("Error plotting isothermal data\n{}".format(str(e)))
260274
raise
@@ -320,8 +334,8 @@ def helper_P_guess(_T):
320334
tmp.append(p)
321335
PV_isotherms.append(tmp)
322336

323-
PV_isotherms = IsothermalPVStruct(isotherms, list(v_iso_space.tolist()), PV_isotherms)
337+
PV_isotherms = IsothermalPVStruct(
338+
isotherms, list(v_iso_space.tolist()), PV_isotherms
339+
)
324340

325341
return (retliq, retvap, critical_point, PV_isotherms)
326-
327-

0 commit comments

Comments
 (0)