pySIMSalabim 1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. pySIMsalabim/__init__.py +21 -0
  2. pySIMsalabim/aux_funcs/SCLC_funcs.py +561 -0
  3. pySIMsalabim/aux_funcs/__init__.py +0 -0
  4. pySIMsalabim/aux_funcs/addons.py +55 -0
  5. pySIMsalabim/experiments/CV.py +918 -0
  6. pySIMsalabim/experiments/EQE.py +461 -0
  7. pySIMsalabim/experiments/JV_steady_state.py +259 -0
  8. pySIMsalabim/experiments/__init__.py +0 -0
  9. pySIMsalabim/experiments/hysteresis.py +753 -0
  10. pySIMsalabim/experiments/impedance.py +848 -0
  11. pySIMsalabim/experiments/imps.py +630 -0
  12. pySIMsalabim/install/__init__.py +20 -0
  13. pySIMsalabim/install/compile_simsalabim.py +76 -0
  14. pySIMsalabim/install/get_SIMsalabim.py +505 -0
  15. pySIMsalabim/install/get_gnu_parallel.py +107 -0
  16. pySIMsalabim/plots/__init__.py +0 -0
  17. pySIMsalabim/plots/band_diagram.py +209 -0
  18. pySIMsalabim/plots/plot_def.py +19 -0
  19. pySIMsalabim/plots/plot_functions.py +240 -0
  20. pySIMsalabim/tests/__init__.py +0 -0
  21. pySIMsalabim/tests/test_CV.py +91 -0
  22. pySIMsalabim/tests/test_EQE.py +97 -0
  23. pySIMsalabim/tests/test_IMPS.py +92 -0
  24. pySIMsalabim/tests/test_JV.py +88 -0
  25. pySIMsalabim/tests/test_hyst.py +92 -0
  26. pySIMsalabim/tests/test_impedance.py +89 -0
  27. pySIMsalabim/utils/__init__.py +25 -0
  28. pySIMsalabim/utils/clean_up.py +96 -0
  29. pySIMsalabim/utils/device_parameters.py +720 -0
  30. pySIMsalabim/utils/general.py +521 -0
  31. pySIMsalabim/utils/parallel_sim.py +654 -0
  32. pySIMsalabim/utils/utils.py +129 -0
  33. pySIMsalabim-1.dist-info/LICENSE +674 -0
  34. pySIMsalabim-1.dist-info/METADATA +159 -0
  35. pySIMsalabim-1.dist-info/RECORD +37 -0
  36. pySIMsalabim-1.dist-info/WHEEL +5 -0
  37. pySIMsalabim-1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ # from pySIMsalabim.utils import *
2
+
3
+ import os, sys, warnings
4
+
5
+ from . import utils
6
+ from .utils import clean_up, device_parameters, general, parallel_sim, utils
7
+ from .utils.clean_up import *
8
+ from .utils.device_parameters import *
9
+ from .utils.general import *
10
+ from .utils.parallel_sim import *
11
+ from .utils.utils import *
12
+
13
+ from . import plots
14
+ from .plots import plot_def, plot_functions, band_diagram
15
+ from .plots.plot_def import *
16
+ from .plots.plot_functions import *
17
+ from .plots.band_diagram import *
18
+
19
+ from . import aux_funcs
20
+ from .aux_funcs import addons
21
+ from .aux_funcs.addons import *
@@ -0,0 +1,561 @@
1
+ ###################################################
2
+ ############### Useful function ###################
3
+ ###################################################
4
+ # by Vincent M. Le Corre
5
+ # Package import
6
+ import subprocess,shutil,os,glob,sys,warnings
7
+ import numpy as np
8
+ import pandas as pd
9
+ import matplotlib.pyplot as plt
10
+ from scipy import stats,optimize,constants
11
+ from lmfit import Model
12
+ # Don't show warnings
13
+ warnings.filterwarnings("ignore")
14
+ ## Physics constants
15
+ q = constants.value(u'elementary charge')
16
+ eps_0 = constants.value(u'electric constant')
17
+ kb = constants.value(u'Boltzmann constant in eV/K')
18
+ k = constants.value(u'Boltzmann constant')
19
+ #############################################################
20
+ ################ SCLC analysis functions ####################
21
+ #############################################################
22
+
23
+ def MottGurney(V,mu,eps_r,Vbi,L):
24
+ """Mott-Gurney equation typically used to fit single carrier devices JVs to get the mobility.
25
+
26
+ J = (9/8)*eps_0*eps_r*mu*((V-Vbi)**2)/(L**3)
27
+
28
+ Refs:
29
+ Mott N F and Gurney R W 1940 Electronic Processes in Ionic Crystals (Oxford: Oxford University Press)
30
+ Nice paper to read on MG ==> J. Phys.: Condens. Matter 30 (2018) 105901
31
+
32
+ Parameters
33
+ ----------
34
+ V : 1-D sequence of floats
35
+ Array containing the voltages (V)
36
+ mu : float
37
+ Mobility (m^2/(Vs))
38
+ eps_r : float
39
+ Relative dielectric constant
40
+ Vbi : float
41
+ Built-in voltage (V)
42
+ L : float
43
+ Thickness (m)
44
+
45
+ Returns
46
+ -------
47
+ 1-D sequence of floats
48
+ Array containing the current-density (A m^-2)
49
+ """
50
+ return (9/8)*eps_0*eps_r*mu*((V-Vbi)**2)/(L**3)
51
+
52
+
53
+ def fit_MottGurney(V,J,mu,eps_r,Vbi,L,var2fit=['mu']):
54
+ """Fit the Mott-Gurney equation to the data
55
+
56
+ Parameters
57
+ ----------
58
+ V : 1-D sequence of floats
59
+ Array containing the voltages (V)
60
+ J : 1-D sequence of floats
61
+ Array containing the current-density (A m^-2)
62
+ mu : float
63
+ Mobility (m^2/(Vs))
64
+ eps_r : float
65
+ Relative dielectric constant
66
+ Vbi : float
67
+ Built-in voltage (V)
68
+ L : float
69
+ Thickness (m)
70
+ var2fit : list, optional
71
+ Chose variable to fit (can be multiple), by default ['mu']
72
+
73
+ Returns
74
+ -------
75
+ list
76
+ list of the fitted values in the same order than var2fit
77
+ """
78
+ fixed_var = ['V','mu','eps_r','Vbi','L']
79
+ for i in var2fit:
80
+ if i in fixed_var:
81
+ fixed_var.remove(i)
82
+
83
+ Mod_MottGurney = Model(MottGurney, independent_vars=fixed_var)
84
+ result = Mod_MottGurney.fit(J, V=V,mu=mu,eps_r=eps_r,Vbi=Vbi,L=L)
85
+
86
+ best_fit = []
87
+ for i in var2fit:
88
+ best_fit.append(result.params[i].value)
89
+ return best_fit
90
+
91
+ def deriv(x,y):
92
+ """Get the derivative of input data dy/dx
93
+
94
+ Parameters
95
+ ----------
96
+ x : 1-D sequence of floats
97
+ x-axis data
98
+ y : 1-D sequence of floats
99
+ y-axis data
100
+
101
+ Returns
102
+ -------
103
+ 1-D sequence of floats
104
+ dy/dx
105
+ """
106
+ dy = np.diff(y)/np.diff(x)
107
+ dum = (y[-1] - y[-2])/(x[-1] - x[-2])
108
+ dy = np.append(dy,[dum])
109
+ # dum = (y[1] - y[0])/(x[1] - x[0])
110
+ # dy = np.append([dum],dy)
111
+ return list(dy)
112
+
113
+ def log_slope(x,y):
114
+ """Get the slope of the logarithmic data
115
+
116
+ Parameters
117
+ ----------
118
+ x : 1-D sequence of floats
119
+ x-axis data
120
+ y : 1-D sequence of floats
121
+ y-axis data
122
+
123
+ Returns
124
+ -------
125
+ 1-D sequence of floats
126
+ slope of the logarithmic data
127
+ """
128
+ # Convert data into np.arrays
129
+ x = np.asarray(x)
130
+ y = np.asarray(y)
131
+ # remove V = 0V before getting log
132
+ if 0 in x:
133
+ idx_0 = x.index(0)
134
+ x = x.pop(idx_0)
135
+ y = y.pop(idx_0)
136
+ log_xf = np.log(x)
137
+ log_yf = np.log(y)
138
+ # Take derivative of data
139
+ slopef = deriv(log_xf,log_yf)
140
+ return np.asarray(slopef)
141
+
142
+ def calc_Vsat(L,Nc,phi,eps_r,T):
143
+ """ Calculate Vsat for SCLC measurement
144
+ as defined in equation (15) in https://doi.org/10.1021/acsenergylett.0c02599
145
+
146
+ Vsat = (8/9) * ((q*Nc*L**2)/(eps_0*eps_r))*exp(-q*phi/k*T)
147
+
148
+ Parameters
149
+ ----------
150
+ L : float
151
+ Thickness (m)
152
+ Nc : float
153
+ Effective density of states (m^-3)
154
+ phi : float
155
+ Injection barrier (V)
156
+ eps_r : float
157
+ Relative dielectric constant
158
+ T : float
159
+ Temperature (K)
160
+
161
+ Returns
162
+ -------
163
+ float
164
+ returns Vsat as defined in
165
+ """
166
+ Vsat = (8/9) * ((q*Nc*L**2)/(eps_0*eps_r))*np.exp(-(q*phi)/(k*T))
167
+ return Vsat
168
+
169
+ def calc_Vtfl(traps,L,eps_r):
170
+ """Calculate VTFL for SCLC measurement
171
+ as defined in equation (2) in ACS Energy Lett. 2021, 6, 3, 1087–1094
172
+ https://doi.org/10.1021/acsenergylett.0c02599
173
+
174
+ Vnet = q * n_traps * L**2 /( 2 * eps_0 * eps_r)
175
+
176
+ Parameters
177
+ ----------
178
+ traps : float
179
+ Trap density (m^-3)
180
+ L : float
181
+ Thickness (m)
182
+ eps_r : float
183
+ Relative dielectric constant
184
+
185
+ Returns
186
+ -------
187
+ float
188
+ returns vnet as defined in
189
+ """
190
+ vtfl = q * (traps) * L**2 /( 2 * eps_0 * eps_r)
191
+ return vtfl
192
+
193
+ def calc_trap_charge(Vnet,L,eps_r):
194
+ """Calculate the trap charges for SCLC measurement
195
+ as defined in equation (2) in ACS Energy Lett. 2021, 6, 3, 1087–1094
196
+ https://doi.org/10.1021/acsenergylett.0c02599
197
+
198
+ Vnet = q * n_trap * L**2 /( 2 * eps_0 * eps_r)
199
+
200
+ Note that if there are not ions or dopant n_net = traps
201
+
202
+ Parameters
203
+ ----------
204
+ Vtfl : float
205
+ Vtfl see ref
206
+ L : float
207
+ Thickness (m)
208
+ eps_r : float
209
+ Relative dielectric constant
210
+
211
+ Returns
212
+ -------
213
+ float
214
+ trapped charges in the bulk
215
+ """
216
+ n_trap = Vtfl * ( 2 * eps_0 * eps_r)/ (q * L**2)
217
+ return n_trap # m^-3
218
+
219
+ def calc_Vnet_with_ions(ions,traps,L,eps_r):
220
+ """Calculate Vnet for SCLC measurement in the presence of Ions
221
+ as defined in equation (4) in ACS Energy Lett. 2021, 6, 3, 1087–1094
222
+ https://doi.org/10.1021/acsenergylett.0c02599
223
+
224
+ Vnet = q * n_net * L**2 /( 2 * eps_0 * eps_r) = q * (traps-ions) * L**2 /( 2 * eps_0 * eps_r)
225
+
226
+ Parameters
227
+ ----------
228
+ ions : float
229
+ Ion density (m^-3)
230
+ traps : float
231
+ Trap density (m^-3)
232
+ L : float
233
+ Thickness (m)
234
+ eps_r : float
235
+ Relative dielectric constant
236
+
237
+ Returns
238
+ -------
239
+ float
240
+ returns vnet as defined in
241
+ """
242
+ vnet = q * (traps-ions) * L**2 /( 2 * eps_0 * eps_r)
243
+ return vnet
244
+
245
+ def calc_net_charge(Vnet,L,eps_r):
246
+ """Calculate the net charge for SCLC measurement
247
+ as defined in equation (4) in ACS Energy Lett. 2021, 6, 3, 1087–1094
248
+ https://doi.org/10.1021/acsenergylett.0c02599
249
+
250
+ Vnet = q * n_net * L**2 /( 2 * eps_0 * eps_r)
251
+
252
+ Note that if there are not ions or dopant n_net = traps
253
+
254
+ Parameters
255
+ ----------
256
+ Vnet : float
257
+ Vnet see ref
258
+ L : float
259
+ Thickness (m)
260
+ eps_r : float
261
+ Relative dielectric constant
262
+
263
+ Returns
264
+ -------
265
+ float
266
+ net-charge in the bulk
267
+ """
268
+ net_charge= Vnet * ( 2 * eps_0 * eps_r)/ (q * L**2)
269
+ return net_charge # m^-3
270
+
271
+ def calc_nt_min(L,eps_r,T):
272
+ """Calculate the minimum appearant trap density for SCLC measurement
273
+ as defined in equation (3) in ACS Energy Lett. 2021, 6, 3, 1087–1094
274
+ https://doi.org/10.1021/acsenergylett.0c02599
275
+
276
+ Ntmin = 4*np.Pi()**2*((k*T)/(q**2))*((eps_0*eps_r)/(L**2))
277
+
278
+ Parameters
279
+ ----------
280
+ L : float
281
+ Thickness (m)
282
+ eps_r : float
283
+ Relative dielectric constant
284
+ T : float
285
+ Temperature (K)
286
+
287
+ Returns
288
+ -------
289
+ float
290
+ minimum appearant trap density
291
+ """
292
+ Ntmin = 4*np.pi**2*((k*T)/(q**2))*((eps_0*eps_r)/(L**2))
293
+ return Ntmin # m^-3
294
+
295
+
296
+ def SCLC_get_data_plot(volt,curr):
297
+ """Get the data for the SCLC plot
298
+
299
+ Parameters
300
+ ----------
301
+ volt : 1-D sequence of floats
302
+ Voltage data
303
+ curr : 1-D sequence of floats
304
+ Current data
305
+
306
+ Returns
307
+ -------
308
+ V_slopef : 1-D sequence of floats
309
+ Voltage data after filtering
310
+ J_slopef : 1-D sequence of floats
311
+ Current data after filtering
312
+ slopesf : 1-D sequence of floats
313
+ logarithmic slopes of the JV after filtering
314
+ get_tangentf : bool
315
+ True if tangents are calculated i.e. if max(slopef) > 2, False if not
316
+ idx_maxf : int
317
+ index of the max slope of the JV after filtering
318
+ max_slopesf : float
319
+ max slope of the JV after filtering
320
+ tang_val_V1f : 1-D sequence of floats
321
+ tangent values of the JV after filtering for the first tangent point. Typically crossing between the ohmic and Trap filled limited regime.
322
+ tang_val_V2f : 1-D sequence of floats
323
+ tangent values of the JV after filtering for the second tangent point (here the inflexion point)
324
+ tang_val_V3f : 1-D sequence of floats
325
+ tangent values of the JV after filtering for the third tangent point. Typically crossing between the Trap filled limited regime and the Mott-Gurney regime.
326
+ V1f : float
327
+ Voltage value of the first crossing point
328
+ J1f : float
329
+ current value of the first crossing point
330
+ V2f : float
331
+ Voltage value of the second crossing point
332
+ J2f : float
333
+ current value of the second crossing point
334
+ Vinf : float
335
+ Voltage value of the inflexion point
336
+ Jinf : float
337
+ current value of the inflexion point
338
+
339
+ """
340
+
341
+ volt = np.asarray(volt)
342
+ curr = np.asarray(curr)
343
+
344
+ # remove volt = 0V before getting log
345
+ if 0 in volt:
346
+ idx_0 = np.where(volt == 0)[0][0]
347
+ volt = np.delete(volt,idx_0)
348
+ curr = np.delete(curr,idx_0)
349
+
350
+ # if we get a 0 or negative value in volt or curr raise an error
351
+ if 0 in volt or 0 in curr:
352
+ raise ValueError('We got a 0 value in the voltage or current data, please check your input data')
353
+ if any(i < 0 for i in volt) or any(i < 0 for i in curr):
354
+ raise ValueError('We got a negative value in the voltage or current data, please check your input data')
355
+
356
+ # remove first offset_noise points in case it is noisy
357
+ # offset_noise = 0
358
+ # volt = volt[offset_noise:]
359
+ # curr = curr[offset_noise:]
360
+
361
+ slopesf = log_slope(volt,curr)
362
+ V_slopef = np.asarray(volt)
363
+ J_slopef = np.asarray(curr)
364
+
365
+ # Get max slope if max slopes > 2.2
366
+ idx_maxf = np.argmax(slopesf)
367
+ max_slopesf = slopesf[idx_maxf]
368
+
369
+ if max_slopesf>2.0:
370
+ get_tangentf = 1
371
+ else: get_tangentf = 0
372
+
373
+
374
+ # Calculate tangent and crossing point
375
+ tang_val_V1f,tang_val_V2f,tang_val_V3f,V1f,J1f,V2f,J2f,Vinf,Jinf = [],[],[],[],[],[],[],[],[]
376
+ if get_tangentf == 1:
377
+ tang_val_V1f = np.exp(np.log(J_slopef[0])+slopesf[0]*(np.log(V_slopef)-np.log(V_slopef[0])))
378
+ tang_val_V2f = np.exp(np.log(J_slopef[idx_maxf])+max_slopesf*(np.log(V_slopef)-np.log(V_slopef[idx_maxf])))
379
+ tang_val_V3f = np.exp(np.log(J_slopef[-1])+slopesf[-1]*(np.log(V_slopef)-np.log(V_slopef[-1])))
380
+ V1f = np.exp((1/(slopesf[0]-max_slopesf)*np.log((J_slopef[idx_maxf]*(V_slopef[0]**slopesf[0]))/(J_slopef[0]*(V_slopef[idx_maxf]**max_slopesf)))))
381
+ J1f = np.exp(np.log(J_slopef[0])+slopesf[0]*(np.log(V1f)-np.log(V_slopef[0])))
382
+ V2f = np.exp((1/(slopesf[-1]-max_slopesf)*np.log((J_slopef[idx_maxf]*(V_slopef[-1]**slopesf[-1]))/(J_slopef[-1]*(V_slopef[idx_maxf]**max_slopesf)))))
383
+ J2f = np.exp(np.log(J_slopef[-1])+slopesf[-1]*(np.log(V2f)-np.log(V_slopef[-1])))
384
+ Vinf = V_slopef[idx_maxf]
385
+ Jinf = J_slopef[idx_maxf]
386
+
387
+ # print(calc_net_charge(V1,thick))
388
+ # print(calc_net_charge(V2,thick))
389
+
390
+ return V_slopef,J_slopef,slopesf,get_tangentf,idx_maxf,max_slopesf,tang_val_V1f,tang_val_V2f,tang_val_V3f,V1f,J1f,V2f,J2f,Vinf,Jinf
391
+
392
+ def Make_SCLC_plot(ax,data_JV,x='Vext',y=['Jext'],show_tangent=[1,2,3],xlimits=[],ylimits=[],plot_type=0,labels='',colors='b',line_type = ['-'],mark='',legend=True,plot_jvexp=False,data_JVexp=pd.DataFrame(),save_yes=False,pic_save_name='JV.jpg'):
393
+ """ Make typical plot for SCLC measurement analysis for SIMsalabim
394
+
395
+ Parameters
396
+ ----------
397
+ num_fig : int
398
+ number of the fig to plot JV
399
+
400
+ data_JV : DataFrame
401
+ Panda DataFrame containing JV_file
402
+
403
+ x : str, optional
404
+ xaxis data (default = 'Vext'), by default 'Vext'
405
+
406
+ y : list of str, optional
407
+ yaxis data can be multiple like ['Jext','Jbimo'] (default = ['Jext']), by default ['Jext']
408
+
409
+ show_tangent : list of int, optional
410
+ show tangent line at V1,Vinf,V2 (default = [1,2,3]), by default [1,2,3]
411
+
412
+ xlimits : list, optional
413
+ x axis limits if = [] it lets python chose limits, by default []
414
+
415
+ ylimits : list, optional
416
+ y axis limits if = [] it lets python chose limits, by default []
417
+
418
+ plot_type : int, optional
419
+ type of plot 1 = logx, 2 = logy, 3 = loglog else linlin (default = linlin), by default 0
420
+
421
+ labels : str, optional
422
+ label of the JV, by default ''
423
+
424
+ colors : str, optional
425
+ color for the JV line, by default 'b'
426
+
427
+ line_type : list, optional
428
+ type of line for simulated data plot
429
+ size line_type need to be = size(y), by default ['-']
430
+
431
+ mark : str, optional
432
+ type of Marker for the JV, by default ''
433
+
434
+ legend : bool, optional
435
+ Display legend or not, by default True
436
+
437
+ plot_jvexp : bool, optional
438
+ plot an experimental JV or not, by default False
439
+
440
+ data_JVexp : [type], optional
441
+ Panda DataFrame containing experimental JV_file with 'V' the voltage and 'J' the current, by default pd.DataFrame()
442
+
443
+ save_yes : bool, optional
444
+ If True, save JV as an image with the file name defined by "pic_save_name", by default False
445
+
446
+ pic_save_name : str, optional
447
+ name of the file where the figure is saved, by default 'JV.jpg'
448
+
449
+ Returns
450
+ -------
451
+ Vslopef : list
452
+ list of of the Voltage values after filtering
453
+ Jslopef : list
454
+ list of of the current values after filtering
455
+ slopesf : list
456
+ list of logarithmic slopes of the JV after filtering
457
+ get_tangentf : bool
458
+ True if tangents are calculated i.e. if max(slopef) > 2, False if not
459
+ idx_maxf : int
460
+ index of the max slope of the JV after filtering
461
+ max_slopesf : float
462
+ max slope of the JV after filtering
463
+ tang_val_V1f : list
464
+ list of the tangent values of the JV after filtering for the first tangent point. Typically crossing between the ohmic and Trap filled limited regime.
465
+ tang_val_V2f : list
466
+ list of the tangent values of the JV after filtering for the second tangent point (here the inflexion point)
467
+ tang_val_V3f : list
468
+ list of the tangent values of the JV after filtering for the third tangent point. Typically crossing between the Trap filled limited regime and the Mott-Gurney regime.
469
+ V1f : float
470
+ Voltage value of the first crossing point
471
+ J1f : float
472
+ current value of the first crossing point
473
+ V2f : float
474
+ Voltage value of the second crossing point
475
+ J2f : float
476
+ current value of the second crossing point
477
+ Vinf : float
478
+ Voltage value of the inflexion point
479
+ Jinf : float
480
+ current value of the inflexion point
481
+
482
+ """
483
+
484
+ # Filter data for V < 0 and J < 0
485
+ print('In Make_SCLC_plot')
486
+ print('Filtering data for V < 0 and J < 0')
487
+ print('If you want to plot JV with V < 0, you need to change modify your input first')
488
+ data_JV = data_JV[data_JV.Vext > 0]
489
+ data_JV = data_JV[data_JV.Jext > 0]
490
+
491
+ # Get tangent and crossing point data
492
+ if show_tangent != []:
493
+ V_slopef,J_slopef,slopesf,get_tangentf,idx_maxf,max_slopesf,tang_val_V1f,tang_val_V2f,tang_val_V3f,V1f,J1f,V2f,J2f,Vinf,Jinf = SCLC_get_data_plot(np.asarray(data_JV['Vext']),np.asarray(data_JV['Jext']))
494
+ else :
495
+ get_tangentf = False
496
+ if len(y) > len(line_type):
497
+ print('Invalid line_type list, we meed len(y) == len(line_type)')
498
+ print('We will use default line type instead')
499
+ line_type = []
500
+ for counter, value in enumerate(y):
501
+ line_type.append('-')
502
+
503
+ # plt.figure(num_fig)
504
+ # ax_JVs_plot = plt.axes()
505
+ ax_JVs_plot = ax
506
+ for i,line in zip(y,line_type):
507
+ if plot_type == 1:
508
+ ax_JVs_plot.semilogx(data_JV['Vext'],data_JV[i]/10,color=colors,label=labels,linestyle=line,marker=mark,markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
509
+ if plot_jvexp:
510
+ ax_JVs_plot.semilogx(data_JVexp['V'],data_JVexp['J']/10,'o',markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
511
+
512
+
513
+ elif plot_type == 2:
514
+ ax_JVs_plot.semilogy(data_JV['Vext'],data_JV[i]/10,color=colors,label=labels,linestyle=line,marker=mark,markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
515
+ if plot_jvexp:
516
+ ax_JVs_plot.semilogy(data_JVexp['V'],data_JVexp['J']/10,'o',markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
517
+
518
+ elif plot_type == 3:
519
+ ax_JVs_plot.loglog(data_JV['Vext'],data_JV[i]/10,color=colors,label=labels,linestyle=line,marker=mark,markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
520
+ if plot_jvexp:
521
+ ax_JVs_plot.loglog(data_JVexp['V'],data_JVexp['J']/10,'o',markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
522
+
523
+ if get_tangentf and show_tangent != []:
524
+ print('Plotting tangents and crossing points')
525
+ if 1 in show_tangent:
526
+ ax_JVs_plot.loglog(V_slopef,tang_val_V1f/10,color=colors,linestyle=line)
527
+ if 2 in show_tangent:
528
+ ax_JVs_plot.loglog(V_slopef,tang_val_V2f/10,color=colors,linestyle=line)
529
+ if 3 in show_tangent:
530
+ ax_JVs_plot.loglog(V_slopef,tang_val_V3f/10,color=colors,linestyle=line)
531
+ if 1 in show_tangent and 2 in show_tangent:
532
+ ax_JVs_plot.loglog(V1f,J1f/10,'rs',markersize=15)
533
+ if 2 in show_tangent and 3 in show_tangent:
534
+ ax_JVs_plot.loglog(V2f,J2f/10,'m^',markersize=15)
535
+ if 2 in show_tangent:
536
+ ax_JVs_plot.loglog(Vinf,Jinf/10,'bo',markersize=15)
537
+
538
+ else:
539
+ ax_JVs_plot.plot(data_JV['Vext'],data_JV[i]/10,color=colors,label=labels,linestyle=line,marker=mark,markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
540
+ if plot_jvexp:
541
+ ax_JVs_plot.plot(data_JVexp['V'],data_JVexp['J']/10,'o',markeredgecolor=colors,markersize=15,markerfacecolor='None',markeredgewidth = 3)
542
+
543
+
544
+ # legend
545
+ if legend == True:
546
+ plt.legend(loc='best',ncol=2,frameon=False)#,fontsize = 30)
547
+ if xlimits != []:
548
+ plt.xlim(xlimits)
549
+ if ylimits != []:
550
+ plt.ylim(ylimits)
551
+ plt.grid(b=True,which='both')
552
+ plt.xlabel('Applied Voltage [V]')
553
+ plt.ylabel('Current Density [mA cm$^{-2}$]')
554
+ plt.tight_layout()
555
+ if save_yes:
556
+ plt.savefig(pic_save_name,dpi=100,transparent=True)
557
+
558
+ if show_tangent != []:
559
+ return ax,V_slopef,J_slopef,slopesf,get_tangentf,idx_maxf,max_slopesf,tang_val_V1f,tang_val_V2f,tang_val_V3f,V1f,J1f,V2f,J2f,Vinf,Jinf
560
+
561
+
File without changes
@@ -0,0 +1,55 @@
1
+ """Useful helper functions for pySIMsalabim"""
2
+ ######### Package Imports #########################################################################
3
+
4
+
5
+ ######### Function Definitions ####################################################################
6
+
7
+ def sci_notation(number, sig_fig=2):
8
+ """Make proper scientific notation for graphs
9
+
10
+ Parameters
11
+ ----------
12
+ number : float
13
+ Number to put in scientific notation.
14
+
15
+ sig_fig : int, optional
16
+ Number of significant digits (Defaults = 2).
17
+
18
+ Returns
19
+ -------
20
+ output : str
21
+ String containing the number in scientific notation
22
+ """
23
+ if sig_fig != -1:
24
+ if number == 0:
25
+ output = '0'
26
+ else:
27
+ ret_string = "{0:.{1:d}e}".format(number, sig_fig)
28
+ a,b = ret_string.split("e")
29
+ if int(b) >= 0:
30
+ b = int(b) #removed leading "+" and strips leading zeros too.
31
+ c = ''
32
+ else:
33
+ b = abs(int(b))
34
+ c = u"\u207B" # superscript minus sign
35
+ SUP = str.maketrans("0123456789", "⁰¹²³⁴⁵⁶⁷⁸⁹")
36
+ b = str(b).translate(SUP)
37
+ output =a + ' x 10' + c + b
38
+ else:
39
+ if number == 0:
40
+ output = '0'
41
+ else:
42
+ ret_string = "{0:.{1:d}e}".format(number, 0)
43
+ a,b = ret_string.split("e")
44
+ b = int(b) #removed leading "+" and strips leading zeros too.
45
+ if int(b) >= 0:
46
+ b = int(b) #removed leading "+" and strips leading zeros too.
47
+ c = ''
48
+ else:
49
+ b = abs(int(b))
50
+ c = u"\u207B" # superscript minus sign
51
+ SUP = str.maketrans("0123456789", "⁰¹²³⁴⁵⁶⁷⁸⁹")
52
+ #SUB = str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
53
+ b = str(b).translate(SUP)
54
+ output = '10' + c + b
55
+ return output