Example #1
0
       - |_G_|                  |   | R2 
           |                    |___|
           |______________________| 
                              3
"""

import bms
from bms.physical.electrical import Generator, Resistor, ElectricalNode, Capacitor, Ground
from bms.signals.functions import Sinus

U = Sinus('Generator', 4, 5)  # Voltage of generator
R1 = 200  # Resistance in Ohm
R2 = 200  # Resistance in Ohm

n1 = ElectricalNode('1')
n2 = ElectricalNode('2')
n3 = ElectricalNode('3')

gen = Generator(n3, n1, U)
res1 = Resistor(n1, n2, R1)
res2 = Resistor(n2, n3, R2)
gnd = Ground(n3)

ps = bms.PhysicalSystem(4, 300, [gen, res1, res2, gnd], [])
ds = ps.dynamic_system

# ds._ResolutionOrder2()
ds.Simulate()
ds.PlotVariables([[U, n1.variable, n2.variable, n3.variable],
                  [res1.variables[0], res2.variables[0]]])
Example #2
0
import bms
from bms.physical.electrical import Generator, Resistor, ElectricalNode, Capacitor, Ground, Inductor
from bms.signals.functions import Sinus

U = Sinus('Generator', 2, 5)  # Voltage of generator
R = 10  # Resistance in Ohm
C = 0.01  # Capacitance in Fahrads
L = 0.025  # Inductance in Henry

n1 = ElectricalNode('1')
n2 = ElectricalNode('2')
n3 = ElectricalNode('3')
n4 = ElectricalNode('4')

gen = Generator(n4, n1, U)
res = Resistor(n1, n2, R)
cap = Capacitor(n2, n3, C)
ind = Inductor(n3, n4, L)
gnd = Ground(n4)

ps = bms.PhysicalSystem(4, 300, [gen, res, cap, gnd, ind], [])
ds = ps.dynamic_system

#ds._ResolutionOrder3()
d = ds.Simulate()
ds.PlotVariables([[U, n1.variable, n2.variable, n3.variable],
                  [res.variables[0], cap.variables[0]]])

# Validation: analytical solutions
Example #3
0
"""

import bms
from bms.physical.electrical import Battery, Resistor, ElectricalNode, Ground
from bms.signals.functions import Sinus

# U=Sinus('Generator',2,5)# Voltage of generator
R = 10  # Resistance in Ohm
Rint = 10
Umax = 12.5
Umin = 6
C = 3600 * 10
soc = 0.8

n1 = ElectricalNode('1')
n2 = ElectricalNode('2')
# n3=ElectricalNode('3')

Bat = Battery(n1, n2, Umin, Umax, C, soc, Rint)
Res = Resistor(n2, n1, R)
G = Ground(n1)

ps = bms.PhysicalSystem(5000, 50, [Bat, Res, G], [])
ds = ps.dynamic_system

# ds._ResolutionOrder3()
d = ds.Simulate()
ds.PlotVariables([[n1.variable, n2.variable], [Bat.soc], [Bat.variables[0]]])

# Validation: analytical solutions