def __new__(self,name=None): name = name or self.generate_name() obj = sympy.Symbol.__new__(self,name) pynamics.addself(obj,name) return obj
def __init__(self,name = None): super(Frame,self).__init__() self.connections_R = {} self.precomputed_R = {} self.connections_w = {} self.precomputed_w = {} self.reps = {} self.R_tree = TreeNode(self) self.w_tree = TreeNode(self) name = name or self.generate_name() self.name = name self.x = Vector() self.y = Vector() self.z = Vector() self.x_sym = sympy.Symbol(name+'.x') self.y_sym = sympy.Symbol(name+'.y') self.z_sym = sympy.Symbol(name+'.z') self.syms = sympy.Matrix([self.x_sym,self.y_sym,self.z_sym]) self.x.add_component(self,[1,0,0]) self.y.add_component(self,[0,1,0]) self.z.add_component(self,[0,0,1]) r = Rotation(self,self,sympy.Matrix.eye(3)) w = RotationalVelocity(self,self,sympy.Number(0)*self.x) self.add_rotation(r) self.add_w(w) pynamics.addself(self,name)
def __init__(self, name, frame, pCM, mass, inertia, system): self.name = name self.frame = frame self.system = system self.pCM = pCM self.mass = mass self.inertia = inertia self.vCM = self.pCM.diff_in_parts(self.system.newtonian, self.system) self.aCM = self.vCM.diff_in_parts(self.system.newtonian, self.system) self.gravityvector = None self.forcegravity = None self.wNBody = self.system.newtonian.getw_(self.frame) self.alNBody = self.wNBody.diff_in_parts(self.system.newtonian, self.system) self.effectiveforce = self.mass * self.aCM self.momentofeffectiveforce = self.inertia.dot( self.alNBody) + self.wNBody.cross(self.inertia.dot(self.wNBody)) self.KE = .5 * mass * self.vCM.dot(self.vCM) + .5 * self.wNBody.dot( self.inertia.dot(self.wNBody)) # self.linearmomentum = self.mass*self.vCM # self.angularmomentum = self.inertia.dot(self.wNBody) self.system.bodies.append(self) self.adddynamics() pynamics.addself(self, name)
def __init__(self, name, frame, pCM, mass, inertia_CM, system=None, about_point=None, about_point_d=None, about_point_dd=None, vCM=None, aCM=None, wNBody=None, alNBody=None, inertia_about_point=None): system = system or pynamics.get_system() name = name or self.generate_name() self.name = name self.frame = frame self.system = system self.pCM = pCM self.mass = mass self.inertia_CM = inertia_CM self.vCM = vCM or self.pCM.time_derivative(self.system.newtonian, self.system) self.aCM = aCM or self.vCM.time_derivative(self.system.newtonian, self.system) if about_point is None: self.about_point = pCM self.about_point_d = self.vCM self.about_point_dd = self.aCM else: self.about_point = about_point self.about_point_d = about_point_d or self.about_point.time_derivative( self.system.newtonian, self.system) self.about_point_dd = about_point_dd or self.about_point_d.time_derivative( self.system.newtonian, self.system) self.inertia_about_point = inertia_about_point or pynamics.inertia.shift_from_cm( self.inertia_CM, self.pCM, self.about_point, self.mass, self.frame) self.gravityvector = None self.forcegravity = None self.wNBody = wNBody or self.system.newtonian.getw_(self.frame) self.alNBody = alNBody or self.wNBody.time_derivative( self.system.newtonian, self.system) # self.linearmomentum = self.mass*self.vCM # self.angularmomentum = self.inertia.dot(self.wNBody) self.system.bodies.append(self) pynamics.addself(self, name) self.effectiveforces = []
def __new__(self,value=None,name=None,system = None): name = name or self.generate_name() system = system or pynamics.get_system() obj = sympy.Symbol.__new__(self,name) # obj.value = value system.add_constant(obj) if value is not None: system.add_constant_value(obj,value) pynamics.addself(obj,name) return obj
def __new__(cls,name=None,system = None,limit = 3,ii=0,ini = None): system = system or pynamics.get_system() name = name or cls.generate_name() output = [] differentiables = [] for kk,jj in enumerate(range(ii,limit)): if kk==0: subname = name variable = sympy.Symbol.__new__(cls,subname) else: subname = name+'_'+'d'*kk # if jj==limit-1: # variable = Variable(subname) # else: # variable = sympy.Symbol.__new__(cls,subname) variable = sympy.Symbol.__new__(cls,subname) pynamics.addself(variable,subname) output.append(variable) # if jj!=limit-1: # differentiables.append(variable) # system.add_q(variable,jj) differentiables.append(variable) system.add_q(variable,jj) # for item in differentiables: # system.set_derivative(item,None) for kk,(a,a_d) in enumerate(zip(output[:-1],output[1:])): system.set_derivative(a,a_d) if ini is not None: system.set_ini(a,ini[kk]) if len(output)==1: return output[0] else: return output
def __init__(self): self.derivatives = {} self.constants = [] self.constant_values = {} self.forces = [] self.constraints = [] # self.momentum = [] # self.KE = sympy.Number(0) self.bodies = [] self.particles = [] self.q = {} self.replacements = {} self.springs = [] self.t = sympy.Symbol('t') self.ini = {} self.error_tolerance = 1e-16 pynamics.addself(self, pynamics.systemname)
def __new__(cls, sys, name=None, limit=3, ii=0): if name == None: name = 'x{0:d}'.format(cls.ii) cls.ii += 1 differentiables = [] for jj in range(ii, limit): if jj == 0: subname = name variable = sympy.Symbol.__new__(cls, subname) else: subname = name + '_' + 'd' * jj variable = sympy.Symbol.__new__(cls, subname) sys.add_q(variable, jj) pynamics.addself(variable, subname) differentiables.append(variable) for a, a_d in zip(differentiables[:-1], differentiables[1:]): sys.add_derivative(a, a_d) return differentiables
def __init__(self, pCM, mass, name=None, system=None, vCM=None, aCM=None): system = system or pynamics.get_system() name = name or self.generate_name() self.name = name self.pCM = pCM self.mass = mass self.system = system self.vCM = vCM or self.pCM.time_derivative(self.system.newtonian, self.system) self.aCM = aCM or self.vCM.time_derivative(self.system.newtonian, self.system) self.gravityvector = None self.forcegravity = None self.system.particles.append(self) pynamics.addself(self, self.name) self.effectiveforces = []
def __init__(self,name = None): super(Frame,self).__init__() self.connections = {} self.precomputed = {} self.reps = {} if name==None: name=Name.frame() self.name = name self.x = Vector() self.y = Vector() self.z = Vector() self.x_sym = sympy.Symbol(name+'.x') self.y_sym = sympy.Symbol(name+'.y') self.z_sym = sympy.Symbol(name+'.z') self.syms = sympy.Matrix([self.x_sym,self.y_sym,self.z_sym]) self.x.add_component(self,[1,0,0]) self.y.add_component(self,[0,1,0]) self.z.add_component(self,[0,0,1]) self.add_rotation(Rotation(self,self,sympy.Matrix.eye(3),sympy.Number(0)*self.x)) pynamics.addself(self,name)
def __new__(self, name, value, system): obj = sympy.Symbol.__new__(self, name) obj.value = value system.add_constant(obj, value) pynamics.addself(obj, name) return obj
def __new__(self, name): obj = sympy.Symbol.__new__(self, name) pynamics.addself(obj, name) return obj