-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNovonix_Protocol.py
More file actions
executable file
·217 lines (182 loc) · 4.9 KB
/
Novonix_Protocol.py
File metadata and controls
executable file
·217 lines (182 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# -*- coding: utf-8 -*-
import base64
import datetime
import io
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import pandas as pd
import numpy
import scipy
import scipy.signal
from utils import *
from analysisselect import *
from plotinfoselect import *
from ackandcreators import *
from mylayouts import *
from myinput import *
from radioitems import *
from upload import *
from droplist import *
from button import *
from image import *
import os, re, Defs
from Defs import *
from utils import *
Novonix_Table = ["Time","Current (A)","Potential (V)","Capacity (Ah)","Temperature (C)","Circuit Temperature (C)","Coulombic Efficiency (Fg-1)/(Cycle number)","Differential Voltage Analysis (A/V)"]
CURRENT = 5
POTENTIAL = 6
CAPACITY = 7
TEMPERATURE = 8
CIRCUIT_TEMP = 9
COULUMBIC = 10
DVA = 11
def CoulombicEfficiency(file,title,xlabel,ylabel):
if xlabel != '':
plotx = xlabel
else:
plotx = 'Cycle Number'
if ylabel != '':
ploty = ylabel
else:
ploty = 'Coulombic Efficiency (%)'
X = []
Y = []
x = []
y = []
charge, discharge = [], []
cycle = 1
i = 0
nrows = len(file)
while i < nrows:
while( i < nrows and cycle == -int(file[i]['Cycle Number'])):
value = float(file[i]['Capacity (Ah)'])
if( int(file[i]['Cycle Number']) < 0 and value != 0):
discharge.append(value)
i += 1
cycle += 1
while( i < nrows and cycle == int(file[i]['Cycle Number'])):
value = float(file[i]['Capacity (Ah)'])
if( int(file[i]['Cycle Number']) > 0):
charge.append(value)
i += 1
# d. incrementing the cycle
x.append(cycle-1)
if(len(discharge) > 1 and len(charge) > 1 and (max(discharge)-min(discharge)) != 0):
print(len(discharge),len(charge),((max(charge)-min(charge))/(max(discharge)-min(discharge)))*100)
y.append(((max(charge)-min(charge))/(max(discharge)-min(discharge)))*100)
charge, discharge = [], []
print('finish')
return html.Div([
dcc.Graph(
id='graph',
figure={
'data': [
{
'x': x,
'y': y,
'name': 'Trace 1',
'mode': 'lines+markers',
'marker': {'size': 12}
}
],
'layout':{
'title':title,
'xaxis': {
'title':plotx,
'size':18,
'family':'Roboto Condensed Bold'
},
'yaxis': {
'title':ploty,
'size':18,
'family':'Roboto Condensed Bold'
}
}
}
)
]
)
def differentiate(V, Q):
dVdQ = []
plotx = []
V = pd.Series(V)
Q = pd.Series(Q)
# Applies a moving average filter
V_smooth = pd.Series.rolling(V, 1).mean()
Q_smooth = pd.Series.rolling(Q, 1).mean()
#differentiting
dV = numpy.diff(V)
dQ = numpy.diff(Q)
dVdQ = dV/dQ
#applies a gaussian filter and a convolution
g = scipy.signal.gaussian(min(40, len(Q)-1), 2.5)
g = g/sum(g)
dVdQ_gaus = numpy.convolve(dVdQ, g, mode='same')
return dVdQ_gaus
def DVA(file,title,xlabel,ylabel,cycles):
cycle_test = 1
if xlabel != '':
plotx = xlabel
else:
plotx = 'Capacity (Ah)'
if ylabel != '':
ploty = ylabel
else:
ploty = 'dV/dQ'
X, Y = [], []
Q, V = [], []
dQdV = []
cycle, cur_file = 1, 1
i = 0
nrows = len(file)
while i < nrows:
while( i < nrows and cycle == abs(int(file[i]['Cycle Number']))):
valueQ = float(file[i]['Capacity (Ah)'])
valueV = float(file[i]['Potential (V)'])
if(int(file[i]['Cycle Number']) > 0 and valueQ != 0 and valueV != 0):
Q.append(valueQ)
V.append(valueV)
i += 1
cycle = cycle + 1
if(len(Q) > 3 and len(V) > 3 and any([t != Q[0] for t in Q]) ):
window_size= max([3, round(len(V)/50) if round(len(V)/50) % 2 != 0 else round(len(V)/50)+1])
dVdQ = differentiate(V, Q)
if((int(cycle)-2) in cycles):
X.append(Q[1:len(Q)])
Y.append(dVdQ)
V, Q, dVdQ = [], [], []
if len(X) > 0:
return html.Div([
dcc.Graph(
id='graph',
figure={
'data': [
{
'x': X[i],
'y': Y[i],
'mode': 'lines+markers',
'marker': {'size': 12},
'name': 'Cycle {}'.format(cycles[i]),
}
for i in range(len(X))
],
'layout':{
'title':title,
'xaxis': {
'title':plotx,
'size':18,
'family':'Roboto Condensed Bold',
},
'yaxis': {
'title':ploty,
'size':18,
'family':'Roboto Condensed Bold',
}
}
}
)
])
else:
return None