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
from bms.physical.electrical.electricalnode import ElectricalNode from bms.physical.electrical.battery import Battery from bms.physical.electrical.resistor import Resistor from bms.physical.electrical.ground import Ground from bms.signals.functions import Sinus # U=Sinus('Generator',2,5)# Voltage of generator r = 10 # Resistance in Ohm r_int = 10 u_max = 12.5 u_min = 6 c = 3600 * 10 soc = 0.8 n1 = ElectricalNode('1') n2 = ElectricalNode('2') # n3=ElectricalNode('3') bat = Battery(n1, n2, u_min, u_max, c, soc, r_int) 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
vehicle = TranslationalNode(mass, SCx, friction_v, 'vehicle') engine = ThermalEngine(crankshaft, wmin, wmax, Tmax, fuel_flow) clutch = Clutch(crankshaft, shaft_gb1, Tmax_c) gr1 = GearRatio(shaft_gb1, shaft_gb2, 0.05) brake = Brake(shaft_gb2, Tmax_b) wheels = Wheel(shaft_gb2, vehicle, r) # Commands subs1 = WeightedSum([Vt, vehicle.variable], engine.commands[0], [Ge, -Ge]) v1 = bms.Variable('', hidden=True) subs2 = WeightedSum([Vt, vehicle.variable], v1, [-Gb, Gb], -Vb) sat1 = Saturation(v1, brake.commands[0], 0, 1) # clutch cc = bms.Variable('Clutch command') gc = Gain(crankshaft.variable, cc, 1/(wrc-wec), wec/(wec-wrc)) satc = Saturation(cc, clutch.commands[0], 0, 1) ps = bms.PhysicalSystem(600, 600, [engine, gr1, clutch, wheels, brake], [ subs1, subs2, sat1, gc, satc]) ds = ps.dynamic_system # ds._ResolutionOrder2() ds.Simulate() ds.PlotVariables([[Vt, vehicle.variable], [engine.throttle, brake.commands[0], clutch.commands[0]], [engine.max_torque, engine.variables[0]]]) ds.PlotVariables( [[crankshaft.variable, shaft_gb1.variable, shaft_gb2.variable]]) ds.PlotVariables([[wheels.variables[0], clutch.variables[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]]])
""" 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