示例#1
0
 def PartialDynamicSystem(self, ieq, variable):
     """
     returns dynamical system blocks associated to output variable
     """
     if ieq == 0:
         # U1=0
         if variable == self.variables[0]:
             b1 = FunctionBlock(self.physical_nodes[0].variable,
                                self.max_torque, self.Tmax)
             b2 = Saturation(self.commands[0], self.throttle, 0, 1)
             b3 = Product(self.max_torque, self.throttle, variable)
             return [b1, b2, b3]
示例#2
0
    def partial_dynamic_system(self, ieq, variable):
        """
        returns dynamical system blocks associated to output variable
        """
        if ieq == 0:
            # Soc determination
            # soc=1-UI/CP
            v1 = Variable('UI', hidden=True)  # UI
            v2 = Variable('UI/CP', hidden=True)  # UI/CP
            v3 = Variable('soc0-UI/CP', hidden=True)  # soc0-UI/CP
            b1 = Product(self.u, self.variables[0], v1)
            b2 = ODE(v1, v2, [1], [1, self.c])
            b3 = WeightedSum([v2], v3, [-1], self.initial_soc)
            b4 = Saturation(v3, self.soc, 0, 1)
            b5 = WeightedSum([self.soc], self.u, [self.u_max - self.u_min],
                             self.u_min)
            blocks = [b1, b2, b3, b4, b5]
        # U2-U1=U+Ri1
        # U=soc(Umax-Umin)+Umin
        if variable == self.physical_nodes[0].variable:
            print('Bat0#1')
            # U1 is output
            # U1=-U-Ri1+U2
            blocks.append(
                WeightedSum([
                    self.u, self.variables[0], self.physical_nodes[1].variable
                ], variable, [-1, -self.r, 1]))
        elif variable == self.physical_nodes[1].variable:
            print('Bat0#2')
            # U2 is output
            # U2=U1+Ri1+U
            blocks.append(
                WeightedSum([
                    self.physical_nodes[0].variable, self.variables[0], self.u
                ], variable, [1, self.r, 1]))

        elif variable == self.variables[0]:
            print('Bat0#3')
            # i1 is output
            # i1=(-U1+U2-U)/R
            blocks.append(
                WeightedSum([
                    self.physical_nodes[0].variable,
                    self.physical_nodes[1].variable, self.u
                ], variable, [-1 / self.r, 1 / self.r, -1 / self.r]))

        return blocks
示例#3
0
 def PartialDynamicSystem(self, ieq, variable):
     """
     returns dynamical system blocks associated to output variable
     """
     if ieq == 0:
         # C1=-f*Tmax*sign(w1-w2)
         if variable == self.variables[0]:
             ut = Variable('unsigned clutch friction torque', hidden=True)
             b1 = Gain(self.commands[0], ut, self.Tmax)
             dw = Variable('Delta rotationnal speed', hidden=True)
             sdw = Variable('Sign of delta rotationnal speed')
             b2 = WeightedSum([
                 self.physical_nodes[0].variable,
                 self.physical_nodes[1].variable
             ], dw, [-1, 1])
             b3 = Sign(dw, sdw)
             b4 = Product(ut, sdw, variable)
             return [b1, b2, b3, b4]
     elif ieq == 1:
         # C1=-C2
         if variable == self.variables[0]:
             return [Gain(self.variables[1], variable, -1)]
         if variable == self.variables[1]:
             return [Gain(self.variables[0], variable, -1)]
示例#4
0
Pe = bms.Variable(('Electrical power', 'Pe'))
Pm = bms.Variable(('Mechanical power', 'Pm'))

block1 = Subtraction(Wc, W, dW)
block2 = ODE(dW, Ui, [1], [0, tau_i])
block3 = Gain(dW, Up, Gc)
block4 = Sum([Up, Ui], Uc)
block4a = Saturation(Uc, Um, -Umax, Umax)
block5 = Subtraction(Um, e, Uind)
block6 = ODE(Uind, Iind, [1], [R, L])
block7 = Gain(Iind, Tm, k)
block8 = Sum([Tm, Text], T)
block8a = Coulomb(Tm, W, Text, Tr, 2)
block9 = ODE(T, W, [1], [0, J])
block10 = Gain(W, e, k)
block11 = Product(Um, Iind, Pe)
block11a = Product(Tm, W, Pm)
ds = bms.DynamicSystem(10, 1000, [
    block1, block2, block3, block4, block4a, block5, block6, block7, block8,
    block8a, block9, block10, block11, block11a
])

# ds.DrawModel()
r = ds.Simulate()
# r=ds._ResolutionOrder()
# print(ba)
ds.PlotVariables([
    [Wc, W, dW],
    [Tm, Text, T],
])
ds.PlotVariables([[Um, e, Uind], [Pe, Pm], [Iind]])