def btnGenCV(self): self.Et_type = "CV" # For the plot simuation button to know what to plot self.multSR = False # Sweep parameters: Eini = float(self.box_Eini.text()) Efin = float(self.box_Efin.text()) dE = float(self.box_dE.text()) ns = int(self.box_ns.text()) tini = 0 # Generate Et: self.statusBar().showMessage("Generating potential waveform for CV") # Separates list of scan rates if self.check_Mult_sr.isChecked(): srList = self.box_Mult_sr.toPlainText() srArray = np.asarray(srList.split("\n")) self.sr = np.zeros(np.size(srArray)) nt = int(abs(Efin - Eini) / dE) self.t = np.zeros([nt * ns, np.size(self.sr)]) for i in range(0, np.size(srArray)): self.sr[i] = float(srArray[i]) t, self.E = wf.sweep(Eini, Efin, self.sr[i], dE, ns, tini) self.t[:, i] = t self.multSR = True else: self.multSR = False sr = float(self.box_sr.text()) self.t, self.E = wf.sweep(Eini, Efin, sr, dE, ns, tini) self.btn_plotSweep.setEnabled(True) self.btn_plotStep.setEnabled(False) self.btn_plotSCV.setEnabled(False) self.btnSimulate.setEnabled(True) self.btnPlot.setEnabled(False) self.btnAnimate.setEnabled(False) self.btnSimulate.setText("Simulate CV") self.btnPlot.setText("Plot CV") self.btnAnimate.setText("Animate CV") self.menuSave.setTitle("Save CV") self.statusBar().showMessage("Potential waveform for CV generated.")
Q0 = 210e-6 # C/cm2, charge density for one monolayer D = 1e-5 # cm2/s, diffusion coefficient of R Ageo = 1 # cm2, geometrical area r = np.sqrt(Ageo/np.pi) # cm, radius of electrode ks = 1e0 # cm/s, standard rate constant alpha = 0.5 # transfer coefficient # Potential waveform E0 = 0 # V, standard potential Eini = -0.5 # V, initial potential Efin = 0.5 # V, final potential vertex sr = 1 # V/s, scan rate ns = 2 # number of sweeps dE = 0.0001 # V, potential increment. This value has to be small for BI to approximate the circuit properly t, E = wf.sweep(Eini=Eini, Efin=Efin, dE=dE, sr=sr, ns=ns) # Creates waveform g0 = Q0/F # mol/cm2, maximum coverage for 1 monolayer eps = n*FRT*(E-E0) kf = ks*np.exp(alpha*eps) kb = ks*np.exp(-(1-alpha)*eps) # Simulation parameters nt = np.size(t) dt = t[1] Th = np.ones(nt) #%% Simulation for j in range(1,nt):
DR = 1e-5 ks = 1e8 alpha = 0.5 DY = 1e-5 k1 = 1e-8 # less tan 1e-1 to converge # Potential waveform E0 = 0 # V, standard potential Eini = -0.5 # V, initial potential Efin = 0.5 # V, final potential vertex sr = 1 # V/s, scan rate ns = 2 # number of sweeps dE = 0.005 # V, potential increment. This value has to be small for BI to approximate the circuit properly t, E = wf.sweep(Eini=Eini, Efin=Efin, dE=dE, sr=sr, ns=ns) DOR = DO / DR DYR = DY / DR #%% Simulation parameters nT = np.size(t) # number of time elements dT = 1 / nT # adimensional step time lamb = 0.45 # For the algorithm to be stable, lamb = dT/dX^2 < 0.5 Xmax = 6 * np.sqrt(nT * lamb) # Infinite distance dX = np.sqrt(dT / lamb) # distance increment nX = int(Xmax / dX) # number of distance elements ## Discretisation of variables and initialisation if cRb == 0: # In case only O present in solution CR = np.zeros([nT, nX])