Exemple #1
0
    def __init__(self, bladed_file, root_length=0, rigid=False):
        # Modal element using data from Bladed model
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()
        #self.tmodes = self.tower.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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0,0,self.tower.hubheight])
        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.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        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.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        if rigid:
            for b in (self.blade1, self.blade2, self.blade3):
                self.system.prescribe(b, vel=0)
        
        # setup integrator
        self.integ = Integrator(self.system, ('pos','vel','acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_deflections())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_positions())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.NodeOutput(b.iprox, local=True, deriv=2))
Exemple #2
0
class Turbine(object):
    def __init__(self, bladed_file, root_length=0, rigid=False):
        # Modal element using data from Bladed model
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0,0,self.tower.hubheight])
        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.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        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.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        if rigid:
            for b in (self.blade1, self.blade2, self.blade3):
                self.system.prescribe(b, vel=0)
        
        # setup integrator
        self.integ = Integrator(self.system, ('pos','vel','acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_deflections())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_positions())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.NodeOutput(b.iprox, local=True, deriv=2))

    def set_base_motion(self, dof, w, amp):
        self.base_motion = dof
        self.base_motion_amp = amp
        self.system.prescribe(self.base, part=dof,
                              vel=lambda t: -w   *amp*np.sin(w*t),
                              acc=lambda t: -w**2*amp*np.cos(w*t))

    def set_initial_conditions(self, qm0=None, az0=None, rotor_speed=None):
        # 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
        if az0 is not None:
            self.system.q[self.bearing.istrain][0] = az0
        if self.base_motion is not None:
            self.system.q[self.base.istrain][self.base_motion] = self.base_motion_amp
        if rotor_speed is not None:
            self.system.prescribe(self.bearing, vel=rotor_speed)

    def simulate(self, qm0=None, az0=0.0, rotor_speed=10.0, t1=None,
                 dt=0.01, t0=0.0, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if t1 is None:
            t1 = 4*pi/rotor_speed if (rotor_speed != 0.0) else 2
        
        if init:
            self.system.find_equilibrium()
        
        # simulate
        t,y = self.integ.integrate(t1, dt, t0)
        #for i,lab in enumerate(self.integ.labels):
        #    print "%2d  %s" % (i,lab)
        #return self.t, self.y
        
        # Build results structure
        results = TurbineResults(t, y, self.modes.mode_names)
        return results
    
    def lin(self, qm0=None, az0=None, rotor_speed=None, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if init:
            self.system.find_equilibrium()
            
        # need initial amplitudes for linearisation point
        if qm0 is None: 
            qm0 = self.system.q[self.blade1.istrain]
        linsys = linearisation.LinearisedSystem(self.system, np.tile(qm0, 3))
        return linsys

    def ani(self, results, x=0, y=1):
        H = self.tower.hubheight + self.blade.radii[-1]
        limits = [(-H,H), (-H,H), (-5,H+5)]
        return dynvis.anim(self.system, results.t, results.strains.as_matrix(),
                           (x, y), limits[x], limits[y])
Exemple #3
0
class Turbine(object):
    def __init__(self, bladed_file, root_length=0, rigid=False):
        # Modal element using data from Bladed model
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()
        #self.tmodes = self.tower.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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0,0,self.tower.hubheight])
        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.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        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.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        if rigid:
            for b in (self.blade1, self.blade2, self.blade3):
                self.system.prescribe(b, vel=0)
        
        # setup integrator
        self.integ = Integrator(self.system, ('pos','vel','acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_deflections())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_positions())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.NodeOutput(b.iprox, local=True, deriv=2))

    @property
    def mass(self):
        """Total mass of turbine"""
        return self.tower.total_mass + self.modes.mass * 3
    
    @property
    def inertia(self):
        """Total rotational inertia of turbine about base"""
        inertia = self.tower.total_inertia
        inertia[(0,1),(0,1)] = self.modes.mass * 3 * self.tower.hubheight
        return inertia
        # XXX neglecting rotor rotational inertia

    def set_base_motion(self, dof, w, amp):
        self.base_motion = dof
        self.base_motion_amp = amp
        self.system.prescribe(self.base, part=dof,
                              vel=lambda t: -w   *amp*np.sin(w*t),
                              acc=lambda t: -w**2*amp*np.cos(w*t))

    def set_initial_conditions(self, qm0=None, az0=None, rotor_speed=None):
        # 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
        if az0 is not None:
            self.system.q[self.bearing.istrain][0] = az0
        if self.base_motion is not None:
            self.system.q[self.base.istrain][self.base_motion] = self.base_motion_amp
        if rotor_speed is not None:
            self.system.prescribe(self.bearing, vel=rotor_speed)

    def simulate(self, qm0=None, az0=0.0, rotor_speed=10.0, t1=None,
                 dt=0.01, t0=0.0, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if t1 is None:
            t1 = 4*pi/rotor_speed if (rotor_speed != 0.0) else 2
        
        if init:
            self.system.find_equilibrium()
        
        # simulate
        self.t,self.y = self.integ.integrate(t1, dt, t0)
        for i,lab in enumerate(self.integ.labels()):
            print "%2d  %s" % (i,lab)
        return self.t, self.y
    
    def lin(self, qm0=None, az0=None, rotor_speed=None, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if init:
            self.system.find_equilibrium()

        linsys = linearisation.LinearisedSystem(self.system)
        return linsys

    def ani(self, vs=(0,1), t=None, y=None):
        if t is None: t = self.t
        if y is None: y = self.y
        limits = [(-10,10), (-42,42), (-5,110)]
        return dynvis.anim(self.system, t, y, vs, limits[vs[0]], limits[vs[1]])
Exemple #4
0
class FlappedBladeTurbine(object):
    def __init__(self, bladed_file, root_length=0):
        # Load modes but use a simple flapped blade
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()

        # Calculate equivalent blade properties
        I1 = self.modes.I0[0]
        I2 = self.modes.J0[0,0]
        print I1, I2
        wflap = self.modes.freqs[0]
        bmass = self.modes.mass
        inertia = self.modes.inertia_tensor(np.zeros(len(self.modes.freqs)))
        Xc = [I1 / bmass, 0, 0]
        kflap = I2 * wflap**2

        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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0,0,self.tower.hubheight])
        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.flap1 = Hinge('flap1', [0,1,0])
        self.flap2 = Hinge('flap2', [0,1,0])
        self.flap3 = Hinge('flap3', [0,1,0])
        self.blade1 = RigidBody('blade1', bmass, inertia, Xc)
        self.blade2 = RigidBody('blade2', bmass, inertia, Xc)
        self.blade3 = RigidBody('blade3', bmass, inertia, Xc)
        
        self.flap1.stiffness = self.flap2.stiffness = self.flap3.stiffness = kflap
        
        self.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        self.bearing.add_leaf(root1)
        self.bearing.add_leaf(root2)
        self.bearing.add_leaf(root3)
        root1.add_leaf(self.flap1)
        root2.add_leaf(self.flap2)
        root3.add_leaf(self.flap3)
        self.flap1.add_leaf(self.blade1)
        self.flap2.add_leaf(self.blade2)
        self.flap3.add_leaf(self.blade3)
        self.system = System(self.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        
        # setup integrator
        self.integ = Integrator(self.system, ('pos','vel','acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.NodeOutput(b.iprox, local=True, deriv=2))

    def set_base_motion(self, dof, w, amp):
        self.base_motion = dof
        self.base_motion_amp = amp
        self.system.prescribe(self.base, part=dof,
                              vel=lambda t: -w   *amp*np.sin(w*t),
                              acc=lambda t: -w**2*amp*np.cos(w*t))

    def set_initial_conditions(self, qm0=None, az0=None, rotor_speed=None):
        # initial conditions
        if qm0 is not None:  # initial hinge angle
            self.system.q[self.flap1.istrain][0] = qm0
            self.system.q[self.flap2.istrain][0] = qm0
            self.system.q[self.flap3.istrain][0] = qm0
        if az0 is not None:
            self.system.q[self.bearing.istrain][0] = az0
        if self.base_motion is not None:
            self.system.q[self.base.istrain][self.base_motion] = self.base_motion_amp
        if rotor_speed is not None:
            self.system.prescribe(self.bearing, vel=rotor_speed)

    def simulate(self, qm0=None, az0=0.0, rotor_speed=10.0, t1=None,
                 dt=0.01, t0=0.0, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if t1 is None:
            t1 = 4*pi/rotor_speed if (rotor_speed != 0.0) else 2
        
        if init:
            self.system.find_equilibrium()
        
        # simulate
        t,y = self.integ.integrate(t1, dt, t0)
        #for i,lab in enumerate(self.integ.labels):
        #    print "%2d  %s" % (i,lab)
        #return self.t, self.y
        
        # Build results structure
        results = FlappedTurbineResults(t, y)
        return results
    
    def lin(self, qm0=None, az0=None, rotor_speed=None, init=False):
        # reset
        self.system.q [:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)
        
        if init:
            self.system.find_equilibrium()
            
        # need initial amplitudes for linearisation point
        if qm0 is None: 
            qm0 = self.system.q[self.blade1.istrain]
        linsys = linearisation.LinearisedSystem(self.system, np.tile(qm0, 3))
        return linsys

    def ani(self, results, x=0, y=1):
        H = self.tower.hubheight + self.blade.radii[-1]
        limits = [(-H,H), (-H,H), (-5,H+5)]
        return dynvis.anim(self.system, results.t, results.strains.as_matrix(),
                           (x, y), limits[x], limits[y])
                           
Exemple #5
0
    def __init__(self, bladed_file, root_length=0):
        # Load modes but use a simple flapped blade
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()

        # Calculate equivalent blade properties
        I1 = self.modes.I0[0]
        I2 = self.modes.J0[0,0]
        print I1, I2
        wflap = self.modes.freqs[0]
        bmass = self.modes.mass
        inertia = self.modes.inertia_tensor(np.zeros(len(self.modes.freqs)))
        Xc = [I1 / bmass, 0, 0]
        kflap = I2 * wflap**2

        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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0,0,self.tower.hubheight])
        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.flap1 = Hinge('flap1', [0,1,0])
        self.flap2 = Hinge('flap2', [0,1,0])
        self.flap3 = Hinge('flap3', [0,1,0])
        self.blade1 = RigidBody('blade1', bmass, inertia, Xc)
        self.blade2 = RigidBody('blade2', bmass, inertia, Xc)
        self.blade3 = RigidBody('blade3', bmass, inertia, Xc)
        
        self.flap1.stiffness = self.flap2.stiffness = self.flap3.stiffness = kflap
        
        self.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        self.bearing.add_leaf(root1)
        self.bearing.add_leaf(root2)
        self.bearing.add_leaf(root3)
        root1.add_leaf(self.flap1)
        root2.add_leaf(self.flap2)
        root3.add_leaf(self.flap3)
        self.flap1.add_leaf(self.blade1)
        self.flap2.add_leaf(self.blade2)
        self.flap3.add_leaf(self.blade3)
        self.system = System(self.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        
        # setup integrator
        self.integ = Integrator(self.system, ('pos','vel','acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.NodeOutput(b.iprox, local=True, deriv=2))
Exemple #6
0
tower_height = 90.0
overhang = 0.8
r_root = 0.5
blade_length = 60.0

EIy = 1000e6
EIz = 1000e6

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)

fstiff = 1e6 * diag([1, 1, 5, 1000, 1000, 100])
foundation = FreeJoint('foundation', fstiff, post_transform=rotmat_y(-pi/2))
tower = EulerBeam('tower', tower_height, 3000, 100e6, 300e6, 300e6, 200e6)
nacelle = RigidConnection('nacelle', [0,0,overhang], rotmat_y(100*pi/180))
bearing = Hinge('bearing', [1,0,0])
hb1 = RigidConnection('hb1', np.dot(Rhb1,[0,0,1]), np.dot(Rhb1,Ry))
hb2 = RigidConnection('hb2', np.dot(Rhb2,[0,0,1]), np.dot(Rhb2,Ry))
hb3 = RigidConnection('hb3', np.dot(Rhb3,[0,0,1]), np.dot(Rhb3,Ry))
b1 = EulerBeam('b1',blade_length, 250, 1000e6, EIy, EIz, 200e6)
b2 = EulerBeam('b2',blade_length, 250, 1000e6, EIy, EIz, 200e6)
b3 = EulerBeam('b3',blade_length, 250, 1000e6, EIy, EIz, 200e6)

tower.damping = 0.05

foundation.add_leaf(tower)
tower.add_leaf(nacelle)
nacelle.add_leaf(bearing)
Exemple #7
0
    def __init__(self, bladed_file, root_length=0, rigid=False):
        # Modal element using data from Bladed model
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0, 0, self.tower.hubheight])
        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.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        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.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        if rigid:
            for b in (self.blade1, self.blade2, self.blade3):
                self.system.prescribe(b, vel=0)

        # setup integrator
        self.integ = Integrator(self.system, ('pos', 'vel', 'acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_deflections())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_positions())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(
                dynamics.NodeOutput(b.iprox, local=True, deriv=2))
Exemple #8
0
class Turbine(object):
    def __init__(self, bladed_file, root_length=0, rigid=False):
        # Modal element using data from Bladed model
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0, 0, self.tower.hubheight])
        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.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        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.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)
        if rigid:
            for b in (self.blade1, self.blade2, self.blade3):
                self.system.prescribe(b, vel=0)

        # setup integrator
        self.integ = Integrator(self.system, ('pos', 'vel', 'acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_deflections())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(b.output_positions())
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(
                dynamics.NodeOutput(b.iprox, local=True, deriv=2))

    def set_base_motion(self, dof, w, amp):
        self.base_motion = dof
        self.base_motion_amp = amp
        self.system.prescribe(self.base,
                              part=dof,
                              vel=lambda t: -w * amp * np.sin(w * t),
                              acc=lambda t: -w**2 * amp * np.cos(w * t))

    def set_initial_conditions(self, qm0=None, az0=None, rotor_speed=None):
        # 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
        if az0 is not None:
            self.system.q[self.bearing.istrain][0] = az0
        if self.base_motion is not None:
            self.system.q[self.base.istrain][
                self.base_motion] = self.base_motion_amp
        if rotor_speed is not None:
            self.system.prescribe(self.bearing, vel=rotor_speed)

    def simulate(self,
                 qm0=None,
                 az0=0.0,
                 rotor_speed=10.0,
                 t1=None,
                 dt=0.01,
                 t0=0.0,
                 init=False):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)

        if t1 is None:
            t1 = 4 * pi / rotor_speed if (rotor_speed != 0.0) else 2

        if init:
            self.system.find_equilibrium()

        # simulate
        t, y = self.integ.integrate(t1, dt, t0)
        #for i,lab in enumerate(self.integ.labels):
        #    print "%2d  %s" % (i,lab)
        #return self.t, self.y

        # Build results structure
        results = TurbineResults(t, y, self.modes.mode_names)
        return results

    def lin(self, qm0=None, az0=None, rotor_speed=None, init=False):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)

        if init:
            self.system.find_equilibrium()

        # need initial amplitudes for linearisation point
        if qm0 is None:
            qm0 = self.system.q[self.blade1.istrain]
        linsys = linearisation.LinearisedSystem(self.system, np.tile(qm0, 3))
        return linsys

    def ani(self, results, x=0, y=1):
        H = self.tower.hubheight + self.blade.radii[-1]
        limits = [(-H, H), (-H, H), (-5, H + 5)]
        return dynvis.anim(self.system, results.t, results.strains.as_matrix(),
                           (x, y), limits[x], limits[y])
Exemple #9
0
    def __init__(self, bladed_file, root_length=0):
        # Load modes but use a simple flapped blade
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()

        # Calculate equivalent blade properties
        I1 = self.modes.I0[0]
        I2 = self.modes.J0[0, 0]
        print I1, I2
        wflap = self.modes.freqs[0]
        bmass = self.modes.mass
        inertia = self.modes.inertia_tensor(np.zeros(len(self.modes.freqs)))
        Xc = [I1 / bmass, 0, 0]
        kflap = I2 * wflap**2

        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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0, 0, self.tower.hubheight])
        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.flap1 = Hinge('flap1', [0, 1, 0])
        self.flap2 = Hinge('flap2', [0, 1, 0])
        self.flap3 = Hinge('flap3', [0, 1, 0])
        self.blade1 = RigidBody('blade1', bmass, inertia, Xc)
        self.blade2 = RigidBody('blade2', bmass, inertia, Xc)
        self.blade3 = RigidBody('blade3', bmass, inertia, Xc)

        self.flap1.stiffness = self.flap2.stiffness = self.flap3.stiffness = kflap

        self.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        self.bearing.add_leaf(root1)
        self.bearing.add_leaf(root2)
        self.bearing.add_leaf(root3)
        root1.add_leaf(self.flap1)
        root2.add_leaf(self.flap2)
        root3.add_leaf(self.flap3)
        self.flap1.add_leaf(self.blade1)
        self.flap2.add_leaf(self.blade2)
        self.flap3.add_leaf(self.blade3)
        self.system = System(self.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)

        # setup integrator
        self.integ = Integrator(self.system, ('pos', 'vel', 'acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(
                dynamics.NodeOutput(b.iprox, local=True, deriv=2))
Exemple #10
0
class FlappedBladeTurbine(object):
    def __init__(self, bladed_file, root_length=0):
        # Load modes but use a simple flapped blade
        print "Loading modes from '%s'..." % bladed_file
        self.blade = Blade(bladed_file)
        self.tower = Tower(bladed_file)
        self.modes = self.blade.modal_rep()

        # Calculate equivalent blade properties
        I1 = self.modes.I0[0]
        I2 = self.modes.J0[0, 0]
        print I1, I2
        wflap = self.modes.freqs[0]
        bmass = self.modes.mass
        inertia = self.modes.inertia_tensor(np.zeros(len(self.modes.freqs)))
        Xc = [I1 / bmass, 0, 0]
        kflap = I2 * wflap**2

        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.base = FreeJoint('base')
        self.towerlink = RigidConnection('tower', [0, 0, self.tower.hubheight])
        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.flap1 = Hinge('flap1', [0, 1, 0])
        self.flap2 = Hinge('flap2', [0, 1, 0])
        self.flap3 = Hinge('flap3', [0, 1, 0])
        self.blade1 = RigidBody('blade1', bmass, inertia, Xc)
        self.blade2 = RigidBody('blade2', bmass, inertia, Xc)
        self.blade3 = RigidBody('blade3', bmass, inertia, Xc)

        self.flap1.stiffness = self.flap2.stiffness = self.flap3.stiffness = kflap

        self.base.add_leaf(self.towerlink)
        self.towerlink.add_leaf(self.bearing)
        self.bearing.add_leaf(root1)
        self.bearing.add_leaf(root2)
        self.bearing.add_leaf(root3)
        root1.add_leaf(self.flap1)
        root2.add_leaf(self.flap2)
        root3.add_leaf(self.flap3)
        self.flap1.add_leaf(self.blade1)
        self.flap2.add_leaf(self.blade2)
        self.flap3.add_leaf(self.blade3)
        self.system = System(self.base)

        # Prescribed DOF accelerations - constant rotor speed
        self.base_motion = None
        self.base_motion_amp = 0
        self.system.prescribe(self.bearing, vel=0)
        self.system.prescribe(self.base, vel=0)

        # setup integrator
        self.integ = Integrator(self.system, ('pos', 'vel', 'acc'))
        self.integ.add_output(dynamics.LoadOutput(self.base.iprox))
        self.integ.add_output(dynamics.LoadOutput(self.towerlink.iprox))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.iprox, local=True))
        self.integ.add_output(
            dynamics.LoadOutput(self.bearing.idist[0], local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(dynamics.LoadOutput(b.iprox, local=True))
        for b in (self.blade1, self.blade2, self.blade3):
            self.integ.add_output(
                dynamics.NodeOutput(b.iprox, local=True, deriv=2))

    def set_base_motion(self, dof, w, amp):
        self.base_motion = dof
        self.base_motion_amp = amp
        self.system.prescribe(self.base,
                              part=dof,
                              vel=lambda t: -w * amp * np.sin(w * t),
                              acc=lambda t: -w**2 * amp * np.cos(w * t))

    def set_initial_conditions(self, qm0=None, az0=None, rotor_speed=None):
        # initial conditions
        if qm0 is not None:  # initial hinge angle
            self.system.q[self.flap1.istrain][0] = qm0
            self.system.q[self.flap2.istrain][0] = qm0
            self.system.q[self.flap3.istrain][0] = qm0
        if az0 is not None:
            self.system.q[self.bearing.istrain][0] = az0
        if self.base_motion is not None:
            self.system.q[self.base.istrain][
                self.base_motion] = self.base_motion_amp
        if rotor_speed is not None:
            self.system.prescribe(self.bearing, vel=rotor_speed)

    def simulate(self,
                 qm0=None,
                 az0=0.0,
                 rotor_speed=10.0,
                 t1=None,
                 dt=0.01,
                 t0=0.0,
                 init=False):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)

        if t1 is None:
            t1 = 4 * pi / rotor_speed if (rotor_speed != 0.0) else 2

        if init:
            self.system.find_equilibrium()

        # simulate
        t, y = self.integ.integrate(t1, dt, t0)
        #for i,lab in enumerate(self.integ.labels):
        #    print "%2d  %s" % (i,lab)
        #return self.t, self.y

        # Build results structure
        results = FlappedTurbineResults(t, y)
        return results

    def lin(self, qm0=None, az0=None, rotor_speed=None, init=False):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0
        self.set_initial_conditions(qm0, az0, rotor_speed)

        if init:
            self.system.find_equilibrium()

        # need initial amplitudes for linearisation point
        if qm0 is None:
            qm0 = self.system.q[self.blade1.istrain]
        linsys = linearisation.LinearisedSystem(self.system, np.tile(qm0, 3))
        return linsys

    def ani(self, results, x=0, y=1):
        H = self.tower.hubheight + self.blade.radii[-1]
        limits = [(-H, H), (-H, H), (-5, H + 5)]
        return dynvis.anim(self.system, results.t, results.strains.as_matrix(),
                           (x, y), limits[x], limits[y])