In [1]:
# Definitions of parameters of the circuit
# Capacitance of generator [F]
C = 1e-6
# Parallel resistance (discharging the capacitor in the generator forming the tail of the impulse) [Ohm]
R1 = 4
# Series resistance (forming the head) [Ohm]
R2 = 150
# Inductance of the loop [H]
L = 1e-3
# Capacitance of the test object [F]
Co = 1e-6
In [2]:
# defining the time of the analysis
import numpy as np
t = np.linspace(0,6e-4, 1000)
In [3]:
# Case 1 two capacitors and the resistor
def dx1(y,t):
uco = y[0]
duco = 1/(R2*Co)*(Uo - uco - Co/C*uco)
return [duco]
In [4]:
# initial conditions
Uo = 200
y0 = [0.0]
In [5]:
# time constant
Cz = C*Co/(C+Co)
R2*Cz
Out[5]:
In [6]:
from scipy.integrate import odeint, ode, romb, cumtrapz
X1 = odeint(dx1, y0, t)
In [7]:
uco = X1[:,0]
In [8]:
# the current and the other capacitor voltage
i = 1/(R2)*(Uo - uco - Co/C*uco)
uc = Uo - Co/C*uco
# current starting value
Uo/R2
# discharge voltage
ud = C*Uo/(C+Co)
Uo/R2, ud
Out[8]:
In [9]:
from bokeh.plotting import figure, output_notebook, show
from bokeh.layouts import column
from bokeh.palettes import RdYlGn4
In [10]:
output_notebook()
In [11]:
p = figure(plot_width=800, plot_height=400)
p.line(t, uco, color="firebrick", legend = "cap charging")
p.line(t, uc, legend = "cap discharging")
p.xaxis.axis_label = "time [s]"
p.xaxis.axis_label_text_font_size = "10pt"
p.yaxis.axis_label = "voltage [V]"
p.yaxis.axis_label_text_font_size = "10pt"
p2 = figure(plot_width=800, plot_height=400)
p2.line(t, i, color='#1a9641')
p2.xaxis.axis_label = "time [s]"
p2.xaxis.axis_label_text_font_size = "10pt"
p2.yaxis.axis_label = "current [A]"
p2.yaxis.axis_label_text_font_size = "10pt"
show(column(p, p2))
In [12]:
# Adjustment of parameters for case 2
L = 1e-2 # interesting values for L: 1e-3 (very little influence); 5e-3 (small oscillation); 1e-2 bigger oscillation
t2 = np.linspace(0,10e-4,1000)
In [13]:
# Case 2: two capacitors, resistor and inductor
def dx2(y,t):
i, uco = y[0], y[1]
di = 1/L*(Uo - Co/C*uco - i*R2 - uco)
duco = 1/Co*i
return [di, duco]
In [14]:
# initial conditions
Uo = 200
y02 = [0.0, 0.0]
In [15]:
X2 = odeint(dx2, y02, t2)
In [16]:
i2 = X2[:,0]
uco2 = X2[:,1]
uc2 = Uo - Co/C*uco2
In [17]:
p3 = figure(plot_width=800, plot_height=400)
p3.line(t2, uco2, color="firebrick", legend = "cap charging")
p3.line(t2, uc2, legend = "cap discharging")
p3.xaxis.axis_label = "time [s]"
p3.xaxis.axis_label_text_font_size = "10pt"
p3.yaxis.axis_label = "voltage [V]"
p3.yaxis.axis_label_text_font_size = "10pt"
p4 = figure(plot_width=800, plot_height=400)
p4.line(t2, i2, color='#1a9641')
p4.xaxis.axis_label = "time [s]"
p4.xaxis.axis_label_text_font_size = "10pt"
p4.yaxis.axis_label = "current [A]"
p4.yaxis.axis_label_text_font_size = "10pt"
show(column(p3, p4))
In [18]:
# Adjustment of parameters for case 3
L = 1e-3 # interesting values for L: 1e-3 (very little influence); 5e-3 (small oscillation); 1e-2 bigger oscillation
t3 = np.linspace(0,10e-4,1000)
In [19]:
# Case 3: circuit for the impulse withstand tester
def dx(y,t):
#state vector variables
i2, uco, uc = y[0], y[1], y[2]
di2 = 1/L*(uc-i2*R2-uco)
duco = 1/Co*i2
duc = -1/C*(uc/R1+i2)
return [di2, duco, duc]
In [20]:
# initial conditions
# capacitor voltage [V]
Uo = 200
# vector of the initial conditions
y0 = [0.0, 0.0, Uo]
In [21]:
#from scipy.integrate import odeint, ode, romb, cumtrapz
X = odeint(dx, y0, t3)
In [22]:
i2 = X[:,0]
uco = X[:,1]
uc = X[:,2]
In [23]:
#output_notebook()
p5 = figure(plot_width=800, plot_height=400)
p5.line(t3, uco, color="firebrick", legend ="Object")
p5.xaxis.axis_label = "time [s]"
p5.xaxis.axis_label_text_font_size = "10pt"
p5.yaxis.axis_label = "voltage [V]"
p5.yaxis.axis_label_text_font_size = "10pt"
p7 = figure(plot_width=800, plot_height=400)
p7.line(t3, uc, legend = "Main capacitor")
p7.xaxis.axis_label = "time [s]"
p7.xaxis.axis_label_text_font_size = "10pt"
p7.yaxis.axis_label = "voltage [V]"
p7.yaxis.axis_label_text_font_size = "10pt"
p6 = figure(plot_width=800, plot_height=400)
p6.line(t3, i2, color='#1a9641')
p6.xaxis.axis_label = "time [s]"
p6.xaxis.axis_label_text_font_size = "10pt"
p6.yaxis.axis_label = "current [A]"
p6.yaxis.axis_label_text_font_size = "10pt"
show(column(p5, p7, p6))
In [24]:
# Capacitor discharging to a resistor
def dk(y,t):
u = y[0]
du = -1/(R1*C)*u
return [du]
In [25]:
y03 = [200.0]
In [26]:
X5 = odeint(dk, y03, t3)
In [27]:
u = X5[:,0]
In [28]:
p7 = figure(plot_width=800, plot_height=400, x_range = (0,4e-5))
p7.line(t3, u, color="firebrick")
p7.xaxis.axis_label = "time [s]"
p7.xaxis.axis_label_text_font_size = "10pt"
p7.yaxis.axis_label = "voltage [V]"
p7.yaxis.axis_label_text_font_size = "10pt"
show(p7)
In [ ]: