Example #1
0
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 22 18:42:33 2015

@author: steven
"""

import bms
from bms.signals.functions import Sinus
from bms.blocks.continuous import ODE

K = 1
Q = 0.3
w0 = 3

#e=bms.Step('e',4.)
e = Sinus('e', 4., 5)
s = bms.Variable('s', [0])

block = ODE(e, s, [1], [1, 2 * Q / w0, 1 / w0**2])
ds = bms.DynamicSystem(5, 200, [block])

#ds.DrawModel()
ds.Simulate()
ds.PlotVariables()
Example #2
0
#I2=Sinus(('input','i'),100.)
#O2=bms.Variable(('Output','O'))#
#b=ODE(I2,O2,[0,1],[1])
#ds2=bms.DynamicSystem(15,3000,[b])
#ds2.Simulate()
#ds2.PlotVariables()

#print(b.Mi,b.Mo)
#print()

#==============================================================================
#  Feedback with derivative for stability test
#==============================================================================

I = Step(('input', 'i'), 100.)
AI = bms.Variable(('adapted input', 'ai'), [100.])
dI = bms.Variable(('error', 'dI'))
O = bms.Variable(('Output', 'O'))  #
F = bms.Variable(('Feedback', 'F'))  #

b1 = Gain(I, AI, Ka)
b2 = WeightedSum([AI, dI], F, [1, -1])
b3 = ODE(O, dI, [1, tau], [Kb])
b4 = Gain(F, O, 1 / Kc)
#
#ds.
ds = bms.DynamicSystem(0.1, 20, [b1, b2, b3, b4])
ds.Simulate()
ds.PlotVariables([[I, O, dI, F]])
Example #3
0
from bms.signals.functions import Step, Sinus
from bms.blocks.continuous import Gain, ODE, Sum, Subtraction, Product, WeightedSum
from bms.blocks.nonlinear import CoulombVariableValue, Saturation, Coulomb

Cmax = 300  # Max clutch torque handling
I1 = 1
I2 = 0.25
fv1 = 0.01
fv2 = 0.01
#e=bmsp.Step(1.,'e')

cc = Sinus(('Brake command', 'cc'), 0.5, 0.1, 0, 0.5)
it = Step(('Input torque', 'it'), 100)
rt = Step(('Resistant torque', 'rt'), -80)

tc = bms.Variable(('brake Torque capacity', 'Tc'))
bt = bms.Variable(('brake torque', 'bt'))
w1 = bms.Variable(('Rotational speed shaft 1', 'w1'))
#dw12=bms.Variable(('Clutch differential speed','dw12'))
st1 = bms.Variable(('Sum torques on 1', 'st1'))
et1 = bms.Variable(('Sum of ext torques on 1', 'et1'))

b1 = Gain(cc, tc, Cmax)
b2 = WeightedSum([it, rt], et1, [1, 1])
b3 = CoulombVariableValue(et1, w1, tc, bt, 0.1)
#b3=Coulomb(it,dw12,ct,150)

b4 = ODE(st1, w1, [1], [fv1, I1])
#b5=ODE(st2,w2,[1],[fv2,I2])
b6 = WeightedSum([it, rt, bt], st1, [1, 1, 1])
#b7=WeightedSum([it,rt],et1,[1,1])
Example #4
0
R = 0.3
L = 0.2
J = 0.2
k = 0.17
Tr = 3  # Torque requested on motor output
Gc = 8  # Gain corrector
tau_i = 3
Umax = 48  # Max voltage motor
# Imax=10# Max intensity motor

# e=bmsp.Step(1.,'e')

Wc = Step(('Rotationnal speed command', 'wc'), 100.)

dW = bms.Variable(('delta rotationnal speed', 'dW'))
Up = bms.Variable(('Voltage corrector proportionnal', 'Ucp'))
Ui = bms.Variable(('Voltage corrector integrator', 'Uci'))
Uc = bms.Variable(('Voltage command', 'Uc'))
Um = bms.Variable(('Voltage Input motor', 'Uim'))
e = bms.Variable(('Counter electromotive force', 'Cef'))
Uind = bms.Variable(('Voltage Inductor', 'Vi'))
Iind = bms.Variable(('Intensity Inductor', 'Ii'))
Tm = bms.Variable(('Motor torque', 'Tm'))
Text = bms.Variable(('Resistant torque', 'Tr'))
T = bms.Variable(('Torque', 'T'))
W = bms.Variable(('Rotationnal speed', 'w'))
Pe = bms.Variable(('Electrical power', 'Pe'))
Pm = bms.Variable(('Mechanical power', 'Pm'))

block1 = Subtraction(Wc, W, dW)
Example #5
0
r1 = 0.05

crankshaft = RotationalNode(Ic, friction_c, 'crankshaft')
shaft_gb1 = RotationalNode(Igb1, friction_c, 'shaft gb1')
shaft_gb2 = RotationalNode(Igb2, friction_c, 'shaft gb2')
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],
Example #6
0
from bms.signals.functions import Step, Sinus
from bms.blocks.continuous import Gain, ODE, Sum, Subtraction, Product, WeightedSum
from bms.blocks.nonlinear import CoulombVariableValue, Saturation, Coulomb

Cmax = 1000  # Max clutch torque handling
I1 = 0.5
I2 = 0.25
fv1 = 0.01
fv2 = 0.01
# e=bmsp.Step(1.,'e')

cc = Sinus(('Clutch command', 'cc'), 0.5, 0.1, 0, 0.5)
it = Step(('Input torque', 'it'), 200)
rt = Step(('Resistant torque', 'rt'), -180)

tc = bms.Variable(('Clutch Torque capacity', 'Tc'))
ct = bms.Variable(('clutch torque', 'ct'))
w1 = bms.Variable(('Rotational speed shaft 1', 'w1'))
w2 = bms.Variable(('Rotational speed shaft 2', 'w2'))
dw12 = bms.Variable(('Clutch differential speed', 'dw12'))
st1 = bms.Variable(('Sum torques on 1', 'st1'))
st2 = bms.Variable(('Sum torques on 2', 'st2'))

b1 = Gain(cc, tc, Cmax)
b2 = WeightedSum([w1, w2], dw12, [1, -1])
b3 = CoulombVariableValue(it, dw12, tc, ct, 1)
# b3=Coulomb(it,dw12,ct,150)

b4 = ODE(st1, w1, [1], [fv1, I1])
b5 = ODE(st2, w2, [1], [fv2, I2])
b6 = WeightedSum([it, ct], st1, [1, 1])