class Rotor(object): def __init__(self, mode_source_file, root_length=0): # Modal element using data from Bladed model print "Loading modes from '%s'..." % mode_source_file self.blade = Blade(mode_source_file) self.modes = self.blade.modal_rep() Ry = rotmat_y(-pi / 2) Rhb1 = rotmat_x(0 * 2 * pi / 3) Rhb2 = rotmat_x(1 * 2 * pi / 3) Rhb3 = rotmat_x(2 * 2 * pi / 3) self.bearing = Hinge('bearing', [1, 0, 0]) root1 = RigidConnection('root1', root_length * np.dot(Rhb1, [0, 0, 1]), dot(Rhb1, Ry)) root2 = RigidConnection('root2', root_length * np.dot(Rhb2, [0, 0, 1]), dot(Rhb2, Ry)) root3 = RigidConnection('root3', root_length * np.dot(Rhb3, [0, 0, 1]), dot(Rhb3, Ry)) self.blade1 = ModalElement('blade1', self.modes) self.blade2 = ModalElement('blade2', self.modes) self.blade3 = ModalElement('blade3', self.modes) self.bearing.add_leaf(root1) self.bearing.add_leaf(root2) self.bearing.add_leaf(root3) root1.add_leaf(self.blade1) root2.add_leaf(self.blade2) root3.add_leaf(self.blade3) self.system = System(self.bearing) # Prescribed DOF accelerations - constant rotor speed self.system.prescribe(self.bearing, acc=0.0) # setup integrator self.integ = Integrator(self.system, ('pos', 'vel')) self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox)) self.integ.add_output( dynamics.LoadOutput(self.blade1.iprox, local=True)) self.integ.add_output(self.blade1.output_deflections()) self.integ.add_output(self.blade1.output_positions()) def simulate(self, qm0=None, spin=10.0, t1=1.5, dt=0.01): # reset self.system.q[:] = 0.0 self.system.qd[:] = 0.0 # initial conditions if qm0 is not None: # initial modal amplitudes self.system.q[self.blade1.istrain] = qm0 self.system.q[self.blade2.istrain] = qm0 self.system.q[self.blade3.istrain] = qm0 self.system.qd[self.bearing.istrain][0] = spin # simulate self.t, self.y = self.integ.integrate(t1, dt) for i, lab in enumerate(self.integ.labels()): print "%2d %s" % (i, lab) return self.t, self.y def lin(self, qm0=None, spin=10.0): # reset self.system.q[:] = 0.0 self.system.qd[:] = 0.0 # initial conditions if qm0 is not None: # initial modal amplitudes self.system.q[self.blade1.istrain] = qm0 self.system.q[self.blade2.istrain] = qm0 self.system.q[self.blade3.istrain] = qm0 else: qm0 = np.zeros(self.blade1._nstrain * 3) self.system.prescribe(self.bearing, vel=spin, acc=0.0) self.system.qd[self.bearing.istrain][0] = spin linsys = linearisation.LinearisedSystem(self.system, qm0) return linsys def ani(self, t=None, y=None, planview=True): if t is None: t = self.t if y is None: y = self.y l = 40 if planview: return dynvis.anim(self.system, t, y, (1, 2), (-l, l), (-l, l)) else: return dynvis.anim(self.system, t, y, (0, 1), (-l, l), (-5, 5))
[0, 1, 2, 10], # time [0, 0, 0, 0 ], # x [0, 0, 20, 20], # y [0, 0, 0, 0 ], # z ]) loading = BladeLoading(modes.x, wind_table, None) # Modal element el = ModalElement('el', modes, loading) system = System(el) el0 = ModalElement('el0', modes0, loading) system0 = System(el0) integ = Integrator(system) integ0 = Integrator(system0) integ.add_output(el.output_positions(stations=[16,32])) integ0.add_output(el0.output_positions(stations=[16,32])) #def simulate(system, t1=2.0, dt=0.005): # Load Bladed data for comparison import pybladed.data brun = pybladed.data.BladedRun(path_damped) bladed_defl = np.c_[ brun.get('blade 1 x-deflection;2'), brun.get('blade 1 x-deflection;4'), ] brun0 = pybladed.data.BladedRun(path_undamped) bladed_defl0 = np.c_[ brun0.get('blade 1 x-deflection;2'), brun0.get('blade 1 x-deflection;4'),
towerdef = Tower(bladed_file) modes = towerdef.modal_rep() endmass = 100000 endinertia = 100 el1 = ModalElement('el', modes, distal=False) system1 = System(el1) el2 = ModalElement('el', modes, distal=True) body = RigidBody('body', endmass, inertia=endinertia*np.eye(3)) el2.add_leaf(body) system2 = System(el2) integ1 = Integrator(system1) integ1.add_output(el1.output_positions()) integ2 = Integrator(system2, outputs=('pos','vel','acc')) integ2.add_output(el2.output_positions()) integ2.add_output(dynamics.NodeOutput(body.iprox)) integ2.add_output(dynamics.NodeOutput(body.iprox, deriv=2)) integ2.add_output(dynamics.LoadOutput(body.iprox)) integ2.add_output(dynamics.StrainOutput(el2.imult)) if False: t,y1 = integ1.integrate(20, 0.05) t,y2 = integ2.integrate(20, 0.05) def p(): fig = plt.figure() ax = fig.add_subplot(311) ax.plot(t, y2[3][:,2], 'b-', label='With end mass')
class Rotor(object): def __init__(self, mode_source_file, root_length=0): # Modal element using data from Bladed model print "Loading modes from '%s'..." % mode_source_file self.blade = Blade(mode_source_file) self.modes = self.blade.modal_rep() Ry = rotmat_y(-pi/2) Rhb1 = rotmat_x(0 * 2*pi/3) Rhb2 = rotmat_x(1 * 2*pi/3) Rhb3 = rotmat_x(2 * 2*pi/3) self.bearing = Hinge('bearing', [1,0,0]) root1 = RigidConnection('root1', root_length*np.dot(Rhb1,[0,0,1]), dot(Rhb1,Ry)) root2 = RigidConnection('root2', root_length*np.dot(Rhb2,[0,0,1]), dot(Rhb2,Ry)) root3 = RigidConnection('root3', root_length*np.dot(Rhb3,[0,0,1]), dot(Rhb3,Ry)) self.blade1 = ModalElement('blade1', self.modes) self.blade2 = ModalElement('blade2', self.modes) self.blade3 = ModalElement('blade3', self.modes) self.bearing.add_leaf(root1) self.bearing.add_leaf(root2) self.bearing.add_leaf(root3) root1.add_leaf(self.blade1) root2.add_leaf(self.blade2) root3.add_leaf(self.blade3) self.system = System(self.bearing) # Prescribed DOF accelerations - constant rotor speed self.system.prescribe(self.bearing, acc=0.0) # setup integrator self.integ = Integrator(self.system, ('pos','vel')) self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox)) self.integ.add_output(dynamics.LoadOutput(self.blade1.iprox, local=True)) self.integ.add_output(self.blade1.output_deflections()) self.integ.add_output(self.blade1.output_positions()) def simulate(self, qm0=None, spin=10.0, t1=1.5, dt=0.01): # reset self.system.q [:] = 0.0 self.system.qd[:] = 0.0 # initial conditions if qm0 is not None: # initial modal amplitudes self.system.q[self.blade1.istrain] = qm0 self.system.q[self.blade2.istrain] = qm0 self.system.q[self.blade3.istrain] = qm0 self.system.qd[self.bearing.istrain][0] = spin # simulate self.t,self.y = self.integ.integrate(t1, dt) for i,lab in enumerate(self.integ.labels()): print "%2d %s" % (i,lab) return self.t, self.y def lin(self, qm0=None, spin=10.0): # reset self.system.q [:] = 0.0 self.system.qd[:] = 0.0 # initial conditions if qm0 is not None: # initial modal amplitudes self.system.q[self.blade1.istrain] = qm0 self.system.q[self.blade2.istrain] = qm0 self.system.q[self.blade3.istrain] = qm0 else: qm0 = np.zeros(self.blade1._nstrain * 3) self.system.prescribe(self.bearing, vel=spin, acc=0.0) self.system.qd[self.bearing.istrain][0] = spin linsys = linearisation.LinearisedSystem(self.system, qm0) return linsys def ani(self, t=None, y=None, planview=True): if t is None: t = self.t if y is None: y = self.y l = 40 if planview: return dynvis.anim(self.system, t, y, (1,2), (-l,l), (-l,l)) else: return dynvis.anim(self.system, t, y, (0,1), (-l,l), (-5,5))
towerdef = Tower(bladed_file) modes = towerdef.modal_rep() endmass = 100000 endinertia = 100 el1 = ModalElement('el', modes, distal=False) system1 = System(el1) el2 = ModalElement('el', modes, distal=True) body = RigidBody('body', endmass, inertia=endinertia * np.eye(3)) el2.add_leaf(body) system2 = System(el2) integ1 = Integrator(system1) integ1.add_output(el1.output_positions()) integ2 = Integrator(system2, outputs=('pos', 'vel', 'acc')) integ2.add_output(el2.output_positions()) integ2.add_output(dynamics.NodeOutput(body.iprox)) integ2.add_output(dynamics.NodeOutput(body.iprox, deriv=2)) integ2.add_output(dynamics.LoadOutput(body.iprox)) integ2.add_output(dynamics.StrainOutput(el2.imult)) if False: t, y1 = integ1.integrate(20, 0.05) t, y2 = integ2.integrate(20, 0.05) def p(): fig = plt.figure() ax = fig.add_subplot(311)