示例#1
0
 def testGetInertia(self):
     from proteus import Domain  
     from proteus import SpatialTools as st    
     from proteus.mprans import SpatialTools as mst
     from proteus.mprans import BodyDynamics as bd   
     # parameters
     domain2D = Domain.PlanarStraightLineGraphDomain()
     pos = np.array([1.0, 1.0, 0.0])
     dim = (0.3, 0.385)
     dt, substeps = 0.001, 20  
     caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
     caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
     mst.assembleDomain(domain2D)      
     c2d = caisson2D
     c2d.nd = 2
     mass = c2d.mass = 50.0
     pivot = np.array([(caisson.vertices[0][0]+caisson.vertices[1][0])*0.5, caisson.vertices[0][1], 0.0])
     d = dx, dy, dz = pivot - caisson.barycenter
     # inertia transformation with different pivot 
     Ix = (old_div((dim[0]**2),12.)) + dy**2
     Iy = (old_div((dim[1]**2),12.)) + dx**2
     It = Ix + Iy 
     I = It*mass
     I1 = c2d.getInertia(vec=(0.,0.,1.), pivot=pivot)
     npt.assert_equal(I, I1)
示例#2
0
 def testGetInertia(self):
     from proteus import Domain  
     from proteus import SpatialTools as st    
     from proteus.mprans import SpatialTools as mst
     from proteus.mprans import BodyDynamics as bd   
     # parameters
     domain2D = Domain.PlanarStraightLineGraphDomain()
     pos = np.array([1.0, 1.0, 0.0])
     dim = (0.3, 0.385)
     dt, substeps = 0.001, 20  
     caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
     caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
     mst.assembleDomain(domain2D)      
     c2d = caisson2D
     c2d.nd = 2
     mass = c2d.mass = 50.0
     pivot = np.array([(caisson.vertices[0][0]+caisson.vertices[1][0])*0.5, caisson.vertices[0][1], 0.0])
     d = dx, dy, dz = pivot - caisson.barycenter
     # inertia transformation with different pivot 
     Ix = ((dim[0]**2)/12.) + dy**2
     Iy = ((dim[1]**2)/12.) + dx**2
     It = Ix + Iy 
     I = It*mass
     I1 = c2d.getInertia(vec=(0.,0.,1.), pivot=pivot)
     npt.assert_equal(I, I1)
示例#3
0
    def testOverturningModule(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(dt/substeps)
        Krot = 200000.
        Crot = 2000.
        c2d.Krot, c2d.Crot =  Krot, Crot
        c2d.substeps, c2d.dt, c2d.ang_acc = substeps, dt, c2d.getAngularAcceleration()
        c2d.setFriction(friction=True, m_static=0.0, m_dynamic=0.0, tolerance=0.000001, grainSize=0.02)
        rotation, last_rotation = c2d.Shape.coords_system, c2d.Shape.coords_system
        ang_vel, last_ang_vel = np.array([0., 0., 0.]), np.array([0., 0., 0.])
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        M =  np.array([0., 0., 10.0])
        init_barycenter, last_position = pos, pos     
        c2d.F, c2d.M, c2d.init_barycenter, c2d.last_position = F, M, init_barycenter, last_position  
        eps = 10.**-30
        mass = c2d.mass = 50.0
        # moment and inertia transformations
        pivot = c2d.pivot_friction = np.array([(caisson.vertices[0][0]+caisson.vertices[1][0])*0.5, caisson.vertices[0][1], 0.0])
        barycenter = caisson.barycenter
        distance = dx, dy, dz = pivot - barycenter
        Mpivot = np.array([0., 0., dx*Fy-dy*Fx]) # Moment calculated in pivot
        Mp = M - Mpivot # Moment transformation through the new pivot
        Ix = ((dim[0]**2)/12.) + dy**2
        Iy = ((dim[1]**2)/12.) + dx**2
        It = Ix + Iy    
        I = It*mass
        c2d.springs = True
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        rz0, vrz0 = atan2(last_rotation[0,1], last_rotation[0,0]), last_ang_vel[2]
        arz0 = (Mp[2] - Crot*vrz0 - Krot*rz0) / I
        rz, vrz, arz = bd.runge_kutta(rz0, vrz0, arz0, dt_sub, substeps, Mp[2], Krot, Crot, I, False)
        # calculation with bodydynamics mopdule
        c2d.cV_init = c2d.cV = c2d.cV_last = caisson.vertices
        c2d.inertia = c2d.getInertia(pivot=pivot)
        c2d.overturning_module(dt)    
        # test
        ang_disp = rz - rz0
        npt.assert_equal(c2d.ang_disp[2], ang_disp)
        npt.assert_equal(c2d.ang_vel[2], vrz)
        npt.assert_equal(c2d.ang_acc[2], arz)
示例#4
0
    def testOverturningModule(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(old_div(dt,substeps))
        Krot = 200000.
        Crot = 2000.
        c2d.Krot, c2d.Crot =  Krot, Crot
        c2d.substeps, c2d.dt, c2d.ang_acc = substeps, dt, c2d.getAngularAcceleration()
        c2d.setFriction(friction=True, m_static=0.0, m_dynamic=0.0, tolerance=0.000001, grainSize=0.02)
        rotation, last_rotation = c2d.Shape.coords_system, c2d.Shape.coords_system
        ang_vel, last_ang_vel = np.array([0., 0., 0.]), np.array([0., 0., 0.])
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        M =  np.array([0., 0., 10.0])
        init_barycenter, last_position = pos, pos     
        c2d.F, c2d.M, c2d.init_barycenter, c2d.last_position = F, M, init_barycenter, last_position  
        eps = 10.**-30
        mass = c2d.mass = 50.0
        # moment and inertia transformations
        pivot = c2d.pivot_friction = np.array([(caisson.vertices[0][0]+caisson.vertices[1][0])*0.5, caisson.vertices[0][1], 0.0])
        barycenter = caisson.barycenter
        distance = dx, dy, dz = pivot - barycenter
        Mpivot = np.array([0., 0., dx*Fy-dy*Fx]) # Moment calculated in pivot
        Mp = M - Mpivot # Moment transformation through the new pivot
        Ix = (old_div((dim[0]**2),12.)) + dy**2
        Iy = (old_div((dim[1]**2),12.)) + dx**2
        It = Ix + Iy    
        I = It*mass
        c2d.springs = True
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        rz0, vrz0 = atan2(last_rotation[0,1], last_rotation[0,0]), last_ang_vel[2]
        arz0 = old_div((Mp[2] - Crot*vrz0 - Krot*rz0), I)
        rz, vrz, arz = bd.runge_kutta(rz0, vrz0, arz0, dt_sub, substeps, Mp[2], Krot, Crot, I, False)
        # calculation with bodydynamics mopdule
        c2d.cV_init = c2d.cV = c2d.cV_last = caisson.vertices
        c2d.inertia = c2d.getInertia(pivot=pivot)
        c2d.overturning_module(dt)    
        # test
        ang_disp = rz - rz0
        npt.assert_equal(c2d.ang_disp[2], ang_disp)
        npt.assert_equal(c2d.ang_vel[2], vrz)
        npt.assert_equal(c2d.ang_acc[2], arz)
示例#5
0
    def testStoreLastValues(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])  
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D
        nd = 2
        anglez = radians(5.0)
        rotz = np.array([  [  cos(anglez),  sin(anglez),  0.0 ],
                           [ -sin(anglez),  cos(anglez),  0.0 ],
                           [  0.0,         0.0,           1.0 ] ])

        c2d.calculate_init()

        # Imposing values on rigid body's parameters
        c2d.position = np.array([2.0, 3.0, 0.0])
        c2d.velocity = np.array([0.5, -0.3, 0.0])
        c2d.acceleration = np.array([0.1, 0.2, 0.0])
        c2d.rotation = rotz
        c2d.rotation_euler =  bd.getEulerAngles(rotz)
        c2d.ang_disp = np.array([0.0, 0.0, 0.001])
        c2d.ang_vel = np.array([0.0, 0.0, -0.003])
        c2d.ang_acc = np.array([0.0, 0.0, 0.005])
        c2d.F = np.array([100.0, -300.0, 0.0])
        c2d.M = np.array([0.0, 0.0, 50.0])
        c2d.pivot = c2d.barycenter
        c2d.ux = 0.5
        c2d.uy = 0.05
        c2d.uz = 0.0

        c2d._store_last_values()
        
        npt.assert_equal(c2d.position, c2d.last_position)
        npt.assert_equal(c2d.velocity, c2d.last_velocity)
        npt.assert_equal(c2d.acceleration, c2d.last_acceleration)
        npt.assert_equal(c2d.rotation, c2d.last_rotation)
        npt.assert_equal(c2d.rotation_euler, c2d.last_rotation_euler)
        npt.assert_equal(c2d.ang_disp, c2d.last_ang_disp)
        npt.assert_equal(c2d.ang_vel, c2d.last_ang_vel)
        npt.assert_equal(c2d.ang_acc, c2d.last_ang_acc)
        npt.assert_equal(c2d.F, c2d.last_F)
        npt.assert_equal(c2d.M, c2d.last_M)
        npt.assert_equal(c2d.pivot, c2d.last_pivot)
        npt.assert_equal(c2d.ux, c2d.last_ux)
        npt.assert_equal(c2d.uy, c2d.last_uy)
        npt.assert_equal(c2d.uz, c2d.last_uz)
示例#6
0
    def testStoreLastValues(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])  
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D
        nd = 2
        anglez = radians(5.0)
        rotz = np.array([  [  cos(anglez),  sin(anglez),  0.0 ],
                           [ -sin(anglez),  cos(anglez),  0.0 ],
                           [  0.0,         0.0,           1.0 ] ])

        c2d.calculate_init()

        # Imposing values on rigid body's parameters
        c2d.position = np.array([2.0, 3.0, 0.0])
        c2d.velocity = np.array([0.5, -0.3, 0.0])
        c2d.acceleration = np.array([0.1, 0.2, 0.0])
        c2d.rotation = rotz
        c2d.rotation_euler =  bd.getEulerAngles(rotz)
        c2d.ang_disp = np.array([0.0, 0.0, 0.001])
        c2d.ang_vel = np.array([0.0, 0.0, -0.003])
        c2d.ang_acc = np.array([0.0, 0.0, 0.005])
        c2d.F = np.array([100.0, -300.0, 0.0])
        c2d.M = np.array([0.0, 0.0, 50.0])
        c2d.pivot = c2d.barycenter
        c2d.ux = 0.5
        c2d.uy = 0.05
        c2d.uz = 0.0

        c2d._store_last_values()
        
        npt.assert_equal(c2d.position, c2d.last_position)
        npt.assert_equal(c2d.velocity, c2d.last_velocity)
        npt.assert_equal(c2d.acceleration, c2d.last_acceleration)
        npt.assert_equal(c2d.rotation, c2d.last_rotation)
        npt.assert_equal(c2d.rotation_euler, c2d.last_rotation_euler)
        npt.assert_equal(c2d.ang_disp, c2d.last_ang_disp)
        npt.assert_equal(c2d.ang_vel, c2d.last_ang_vel)
        npt.assert_equal(c2d.ang_acc, c2d.last_ang_acc)
        npt.assert_equal(c2d.F, c2d.last_F)
        npt.assert_equal(c2d.M, c2d.last_M)
        npt.assert_equal(c2d.pivot, c2d.last_pivot)
        npt.assert_equal(c2d.ux, c2d.last_ux)
        npt.assert_equal(c2d.uy, c2d.last_uy)
        npt.assert_equal(c2d.uz, c2d.last_uz)
示例#7
0
    def testStep(self):
        from proteus import Domain
        from proteus import SpatialTools as st
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D,
                                dim=dim,
                                coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)
        c2d = caisson2D
        nd = c2d.nd = 2
        Ix = ((dim[0]**2) / 12.)
        Iy = ((dim[1]**2) / 12.)
        It = Ix + Iy
        mass = 50.0
        I = mass * It
        c2d.mass, c2d.It = mass, It
        init_barycenter, last_position, last_velocity, last_rotation, last_ang_vel = pos, pos * 2.0, np.array(
            [0.05, 0.07,
             0.0]), np.array([0.0, 0.0, 0.0001]), np.array([0., 0., 0.0000002])
        c2d.init_barycenter, c2d.last_position, c2d.last_velocity, c2d.last_rotation, c2d.last_ang_vel = init_barycenter, last_position, last_velocity, last_rotation, last_ang_vel
        F = Fx, Fy, Fz = np.array([200., 300., 0.0])
        M = Mx, My, Mz = np.array([0., 0., 50.0])
        dt, substeps = 0.001, 20
        dt_sub = c2d.dt_sub = float(dt / substeps)
        c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration(
        )
        c2d.InputMotion = False
        c2d.scheme = 'Forward_Euler'
        h, tra_velocity = bd.forward_euler(last_position, last_velocity,
                                           F / mass, dt)
        rot, rot_velocity = bd.forward_euler(last_rotation, last_ang_vel,
                                             M / I, dt)
        if rot[2] < 0.0: rot[2] = -rot[2]
        # 2d calculation
        caisson.translate(h[:nd]), caisson.rotate(rot[2])
        posTra1, rot1 = caisson.barycenter, caisson.coords_system
        # 2d from bodydynamics
        caisson.translate(-h[:nd]), caisson.rotate(-rot[2])
        c2d.step(dt)
        posTra2, rot2 = c2d.position, c2d.rotation[:nd, :nd]
        npt.assert_allclose(posTra1, posTra2, atol=1e-10)
        npt.assert_allclose(rot1, rot2, atol=1e-10)
示例#8
0
    def testGetDisplacement(self):
        from proteus import Domain
        from proteus import SpatialTools as st
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D,
                                dim=dim,
                                coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)
        c2d = caisson2D
        c2d.nd = 2
        Ix = ((dim[0]**2) / 12.)
        Iy = ((dim[1]**2) / 12.)
        It = Ix + Iy
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        Kx, Ky, Kz = K = [200000., 250000., 0.0]
        Cx, Cy, Cz = C = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz = Kx, Ky, Kz, Cx, Cy, Cz
        init_barycenter, last_position, last_velocity = pos, pos * 2.0, np.array(
            [0.05, 0.07, 0.0])
        c2d.init_barycenter, c2d.last_position, c2d.last_velocity = init_barycenter, last_position, last_velocity
        Fx, Fy, Fz = F = np.array([200., 300., 0.0])
        dt, substeps = 0.001, 50
        dt_sub = c2d.dt_sub = float(dt / substeps)
        c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration(
        )

        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        u0 = ux0, uy0, uz0 = last_position - init_barycenter
        v0 = vx0, vy0, vz0 = last_velocity
        a0 = ax0, ay0, az0 = (F - C * v0 - K * u0) / mass
        for ii in range(substeps):
            ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fx,
                                        Kx, Cx, mass, False)
            uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy,
                                        Ky, Cy, mass, False)
            uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz,
                                        Kz, Cz, mass, False)
        h = hx, hy, hz = [ux - ux0, uy - uy0, uz - uz0]
        c2d.h = c2d.getDisplacement(dt)
        npt.assert_equal(c2d.h, h)
示例#9
0
 def testPaddleMotion(self):
     from proteus import Domain
     from proteus.mprans import SpatialTools as mst
     from proteus.mprans.BodyDynamics import PaddleBody
     domain2D = Domain.PlanarStraightLineGraphDomain()        
     pos = np.array([2.0, 0.1 , 0.0])
     dim = (0.3, 1.)
     paddle = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
     
     PB=PaddleBody(paddle,substeps=20)
     PB.calculate_init()
     At  = [1.,0.,0.]
     Ar =  [0.1,0.,0.]
     Tt = Tr = [0.5,0.,0.]
     rampS = 0.1
     rampE = 0.1
     Tend = 2.
     PB.inputMotion(InputMotion=True, pivot=None,
                    At=At, Tt=Tt,
                    Ar=Ar, Tr=Tr,
                    rampStart=rampS, rampEnd =rampE, Tend = Tend)
     # tersting initial ramp
     times= [0.04, 0.95 ,1.93]
     for tt in times:
         ramp = min(1.,tt/rampS,(Tend-tt)/rampE)
         getVars = PB.imposeSinusoidalMotion(tt=tt)
         disp = ramp*np.array(At)*np.sin(2*np.pi/Tt[0]*tt)
         rot =  ramp*np.array(Ar)*np.sin(2*np.pi/Tt[0]*tt)
         disp = disp - (PB.last_position - PB.init_barycenter)
         npt.assert_equal(disp,getVars[0])
         npt.assert_equal(rot,getVars[1])
示例#10
0
 def testCalculate_init(self):
     from proteus import Domain
     from proteus.mprans import SpatialTools as mst
     from proteus.mprans.BodyDynamics import PaddleBody
     domain2D = Domain.PlanarStraightLineGraphDomain()        
     pos = np.array([2.0, 0.1 , 0.0])
     dim = (0.3, 1.)
     paddle = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
     
     PB=PaddleBody(paddle,substeps=20)
     PB.calculate_init()
     npt.assert_equal(PB.position,[pos[0],0.,0.])
     npt.assert_equal(PB.last_position,[pos[0],0.,0.])
     npt.assert_equal(PB.rotation,np.eye(3))
     npt.assert_equal(PB.last_rotation,np.eye(3))
     from proteus.mprans.BodyDynamics import getEulerAngles
     npt.assert_equal(PB.rotation_euler,getEulerAngles(PB.rotation))
     npt.assert_equal(PB.last_rotation_euler,getEulerAngles(PB.last_rotation))
     npt.assert_equal(PB.cV_init,np.array([(1.85,-0.4),
                                           (2.15,-0.4),
                                           (2.15,0.6),
                                           (1.85,0.6)]))
     npt.assert_equal(PB.cV,np.array([(1.85,-0.4),
                                           (2.15,-0.4),
                                           (2.15,0.6),
                                           (1.85,0.6)]))
     npt.assert_equal(PB.cV_last,np.array([(1.85,-0.4),
                                           (2.15,-0.4),
                                           (2.15,0.6),
                                           (1.85,0.6)]))
示例#11
0
    def testStep(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        nd = c2d.nd = 2
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        I = mass*It
        c2d.mass, c2d.It = mass, It
        init_barycenter, last_position, last_velocity, last_rotation, last_ang_vel = pos, pos*2.0, np.array([0.05, 0.07, 0.0]), np.array([0.0, 0.0, 0.0001]), np.array([0., 0., 0.0000002])
        c2d.init_barycenter, c2d.last_position, c2d.last_velocity, c2d.last_rotation, c2d.last_ang_vel = init_barycenter, last_position, last_velocity, last_rotation, last_ang_vel 
        F = Fx, Fy, Fz = np.array([200., 300., 0.0])
        M = Mx, My, Mz = np.array([0., 0., 50.0])
        dt, substeps = 0.001, 20  
        dt_sub = c2d.dt_sub = float(dt/substeps)
        c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration()
        c2d.InputMotion = False
        c2d.scheme = 'Forward_Euler'
        h, tra_velocity = bd.forward_euler(last_position, last_velocity, F/mass, dt)
        rot, rot_velocity = bd.forward_euler(last_rotation, last_ang_vel, M/I, dt)
        if rot[2] < 0.0: rot[2]=-rot[2]
        # 2d calculation
        caisson.translate(h[:nd]), caisson.rotate(rot[2])
        posTra1, rot1 = caisson.barycenter, caisson.coords_system
        # 2d from bodydynamics
        caisson.translate(-h[:nd]), caisson.rotate(-rot[2])
        c2d.step(dt)
        posTra2, rot2 = c2d.position, c2d.rotation[:nd,:nd]
        npt.assert_allclose(posTra1, posTra2, atol=1e-10)
        npt.assert_allclose(rot1, rot2, atol=1e-10)
示例#12
0
    def testGetDisplacement(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        Kx, Ky, Kz = K = [200000., 250000., 0.0]
        Cx, Cy, Cz = C = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        init_barycenter, last_position, last_velocity = pos, pos*2.0, np.array([0.05, 0.07, 0.0])
        c2d.init_barycenter, c2d.last_position, c2d.last_velocity = init_barycenter, last_position, last_velocity 
        Fx, Fy, Fz = F = np.array([200., 300., 0.0])
        dt, substeps = 0.001, 50  
        dt_sub = c2d.dt_sub = float(dt/substeps)
        c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration()

        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        u0 = ux0, uy0, uz0 = last_position - init_barycenter
        v0 = vx0, vy0, vz0 = last_velocity
        a0 = ax0, ay0, az0 = (F - C*v0 - K*u0) / mass
        for ii in range(substeps):
            ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fx, Kx, Cx, mass, False)
            uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
            uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        h = hx, hy, hz = [ux-ux0, uy-uy0, uz-uz0]
        c2d.h = c2d.getDisplacement(dt)
        npt.assert_equal(c2d.h, h)
示例#13
0
    def testGetAngularAcceleration(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])    
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D

        F = np.array([100.0, -200.0, 10.0])
        mass = 150.0
        acceleration = F/mass

        c2d.F = F
        c2d.mass = mass
        c2d.acceleration = c2d.getAcceleration()
        npt.assert_equal(c2d.acceleration, acceleration)
示例#14
0
    def testGetAngularAcceleration(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])    
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D

        F = np.array([100.0, -200.0, 10.0])
        mass = 150.0
        acceleration = old_div(F,mass)

        c2d.F = F
        c2d.mass = mass
        c2d.acceleration = c2d.getAcceleration()
        npt.assert_equal(c2d.acceleration, acceleration)
示例#15
0
    def testCalculateInit(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])  
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D
        nd = 2
        angle = bd.getEulerAngles(rot)

        c2d.calculate_init()

        npt.assert_equal(c2d.position, pos)
        npt.assert_equal(c2d.last_position, pos)
        npt.assert_equal(c2d.rotation, rot)
        npt.assert_equal(c2d.last_rotation, rot)
        npt.assert_equal(c2d.rotation_euler, angle)
        npt.assert_equal(c2d.last_rotation_euler, angle)
示例#16
0
    def testCalculateInit(self):
        from proteus import Domain  
        from proteus.mprans import SpatialTools as st
        from proteus.mprans import BodyDynamics as bd   
        domain = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ])  
        dim=(0.3, 0.385)
        caisson = st.Rectangle(domain, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        st.assembleDomain(domain)      
        c2d = caisson2D
        nd = 2
        angle = bd.getEulerAngles(rot)

        c2d.calculate_init()

        npt.assert_equal(c2d.position, pos)
        npt.assert_equal(c2d.last_position, pos)
        npt.assert_equal(c2d.rotation, rot)
        npt.assert_equal(c2d.last_rotation, rot)
        npt.assert_equal(c2d.rotation_euler, angle)
        npt.assert_equal(c2d.last_rotation_euler, angle)
示例#17
0
coords = [ dimx/2., dimy/2. ]

boundaryOrientations = {'y-': np.array([0., -1.,0.]),
                        'x+': np.array([+1, 0.,0.]),
                        'y+': np.array([0., +1.,0.]),
                        'x-': np.array([-1., 0.,0.]),
                        'sponge': None,
                           }
boundaryTags = {'y-': 1,
                    'x+': 2,
                    'y+': 3,
                    'x-': 4,
                    'sponge': 5,
                       }

tank = st.Rectangle(domain, dim=dim, coords=coords)


#############################################################################################################################################################################################################################################################################################################################################################################################
# ----- BOUNDARY CONDITIONS ----- #
#############################################################################################################################################################################################################################################################################################################################################################################################

tank.BC['y-'].setFreeSlip()

tank.BC['y+'].setAtmosphere(orientation=np.array([0., +1.,0.]))

tank.BC['x-'].setFreeSlip()

tank.BC['x+'].setFreeSlip()

he = opts.he
smoothing = he*3.

# ----- TANK ------ #

sloped_shore = [[[9.22, 0.],
                 [9.64, 0.06],
                 [15.01, 0.06],
                 [27.04, 0.66],
                 [31.04, 0.66],
                 [37.07, 0.06],
                 [45.39, 0.06],
                 [45.81, 0.]],]

tank = st.TankWithObstacles2D(domain=domain,
                              dim=tank_dim,
                              obstacles=sloped_shore)

# ----- GENERATION / ABSORPTION LAYERS ----- #

tank.setSponge(x_n=tank_sponge[0], x_p=tank_sponge[1])
dragAlpha = 10.*omega/1e-6

if opts.generation:
    tank.setGenerationZones(x_n=True, waves=waves, dragAlpha=dragAlpha, smoothing = smoothing)
if opts.absorption:
    tank.setAbsorptionZones(x_p=True, dragAlpha = dragAlpha)

# ----- BOUNDARY CONDITIONS ----- #

# Waves
示例#19
0
##########################################
#              Mesh & Domain             #
##########################################

# ----- DOMAIN ----- #

domain = Domain.PlanarStraightLineGraphDomain()
he = tank_dim[0] / float(4 * refinement - 1)

# ----- TANK ----- #

weir = [[[obstacle_x_start, 0], [obstacle_x_highest, obstacle_height],
         [obstacle_x_end, 0]]]

tank = st.TankWithObstacles2D(domain=domain, dim=tank_dim, obstacles=weir)

# ----- SPONGE & WAVES ----- #
if opts.sponge_layers:
    omega = 1.
    dragAlpha = 5. * omega / nu_0
    tank.setSponge(x_n=opts.tank_sponge[0], x_p=opts.tank_sponge[1])
    tank.setAbsorptionZones(x_n=True, dragAlpha=dragAlpha)
    tank.setAbsorptionZones(x_p=True, dragAlpha=dragAlpha)

if opts.waves:
    # TODO: for now this is an actual wave, which we don't want.  We want a placid
    # wave such that our generation and absorption zones enforce a steady flow.
    omega = 2 * np.pi / 2.
    dragAlpha = 5. * omega / nu_0
    wave = wt.MonochromaticWaves(period=2,
示例#20
0
rho_0 = 1000.
nu_0 = 1.004e-6
rho_1 = 1.205
nu_1 = 1.500e-5
sigma_01 = 0.0
g = [0., -9.81]
he = 0.2
water_level = 2.5

# GEOMETRY

domain = Domain.PlanarStraightLineGraphDomain()

tank_dim = [5., 5.]
tank = st.Tank2D(domain, dim=tank_dim)
rect = st.Rectangle(
    domain,
    dim=[1., 1.],
    coords=[old_div(tank_dim[0], 2.),
            old_div(tank_dim[1], 2.)])
rect.setHoles(holes=np.array([rect.coords]))

domain.MeshOptions.he = he

# BOUNDARY CONDITIONS

tank.BC['x+'].setNoSlip()
tank.BC['x-'].setNoSlip()
tank.BC['y-'].setNoSlip()
tank.BC['y+'].setAtmosphere()
示例#21
0
wavelength = wave.wavelength

#  ____                        _
# |  _ \  ___  _ __ ___   __ _(_)_ __
# | | | |/ _ \| '_ ` _ \ / _` | | '_ \
# | |_| | (_) | | | | | | (_| | | | | |
# |____/ \___/|_| |_| |_|\__,_|_|_| |_|
# Domain
# All geometrical options go here (but not mesh options)

domain = Domain.PlanarStraightLineGraphDomain()

# ----- SHAPES ----- #

# TANK
tank = st.Tank2D(domain, dim=(2 * wavelength, 2 * water_level))

# SPONGE LAYERS
# generation zone: 1 wavelength
# absorption zone: 2 wavelengths
tank.setSponge(x_n=wavelength, x_p=2 * wavelength)

caisson = st.Rectangle(domain, dim=(0.5, 0.2), coords=(0., 0.))
# set barycenter in middle of caisson
caisson.setBarycenter([0., 0.])
# caisson is considered a hole in the mesh
caisson.setHoles([[0., 0.]])
# 2 following lines only for py2gmsh
caisson.holes_ind = np.array([0])
tank.setChildShape(caisson, 0)
# translate caisson to middle of the tank
示例#22
0
he = opts.he

############ TANK ###################

tank_dim = (opts.tank_dim_x, opts.tank_dim_y)

x1 = 0.2

### CYLINDER #####
cylinder_pos = np.array([opts.cylinder_pos_x, opts.cylinder_pos_y, 0.])
cylinder_radius = opts.cylinder_radius

if opts.circle2D:
    circle = st.Circle(domain=domain,
                       radius=cylinder_radius,
                       coords=(cylinder_pos[0], cylinder_pos[1]),
                       barycenter=(cylinder_pos[0], cylinder_pos[1]),
                       nPoints=28)

    circle2D = bd.RigidBody(shape=circle)
    free_x = (0.0, 0.0, 0.0)
    free_r = (0.0, 0.0, 0.0)
    circle2D.setConstraints(free_x=free_x, free_r=free_r)
    circle2D.setNumericalScheme(None)
    circle2D.setRecordValues(filename='circle2D', all_values=True)

boundaryOrientations = {
    'y-': np.array([0., -1., 0.]),
    'x+': np.array([+1, 0., 0.]),
    'y+': np.array([0., +1., 0.]),
    'x-': np.array([-1., 0., 0.]),
示例#23
0
                    'y+': 3,
                    'x-': 4,
                    'sponge': 5,
                    'circle':6,
                       }

##############################################################################################################################################################################################################
# circle2D
############################################################################################################################################################################################################
if opts.circle2D:
    width=opts.width           # The 3rd dimension
    mass=opts.mass             # kg
    I = (3.14*(radius**4)/2.)*mass

# --- Shape properties setup
    circle = st.Circle(domain=domain, radius=opts.radius, coords=(xc1, yc1), barycenter=(xc1, yc1), nPoints=28)

# --- Body properties setup
    circle2D = bd.RigidBody(shape=circle)
    free_x=(0.0, 0.0, 0.0) # Translational DOFs
    free_r=(0.0, 0.0, 0.0) # Rotational DOFs
    if opts.movingDomain==True:
        free_x=(1.0, 1.0, 0.0) # Translational DOFs
        free_r=(0.0, 0.0, 1.0) # Rotational DOFs
    circle2D.setMass(mass)
    circle2D.It= I/circle2D.mass/width
    circle2D.setConstraints(free_x=free_x, free_r=free_r)
    circle2D.setNumericalScheme(scheme=opts.scheme)
    circle2D.inputMotion(InputMotion=opts.InputMotion, At=opts.At, Tt=opts.Tt)
    circle2D.setRecordValues(filename='circle2D', all_values=True)
示例#24
0
    def testFrictionModule(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        #########################
        # 1st case              #
        #########################
        # When sliding is true and caisson already experiences plastic displacements

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(old_div(dt,substeps))
        Ix = (old_div((dim[0]**2),12.))
        Iy = (old_div((dim[1]**2),12.))
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == True. dynamic sign and dynamic friction
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.001, 0.001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps))
        c2d.sliding, sign, m = True, sign_dynamic, m_dynamic
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass)
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx+Ftan
        Kx, Cx = 0.0, 0.0
        ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass)
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt) 
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 0.0, 1.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
         

        #########################
        # 2nd case              #
        #########################
        # When sliding is false but the caisson starts to experience sliding motion

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(old_div(dt,substeps))
        Ix = (old_div((dim[0]**2),12.))
        Iy = (old_div((dim[1]**2),12.))
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == False. static sign and static friction
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.001, 0.001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps))
        c2d.sliding, sign, m = False, sign_static, m_static
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass)
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx+Ftan
        Kx, Cx = 0.0, 0.0
        ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass)
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt)
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 0.0, 1.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
         

        #########################
        # 3rd case              #
        #########################
        # When caisson experiences vibration motion

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(old_div(dt,substeps))
        Ix = (old_div((dim[0]**2),12.))
        Iy = (old_div((dim[1]**2),12.))
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == False. static sign and static friction. Kx and Cx different from 0!
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.00001, 0.00001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps))
        c2d.sliding, sign, m = False, sign_static, m_static
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass)
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx        
        ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass)
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt)
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 1.0, 0.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
示例#25
0
    def testGetInertia(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # 2d case
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        I1 = It*mass
        c2d.mass = mass
        c2d.It = It
        I2 = c2d.getInertia()
        npt.assert_equal(I1, I2)

        # 3d case
        pos, dim, caisson = [], [], []
        domain3D = Domain.PiecewiseLinearComplexDomain()
        pos = np.array([0.0, 0.0, 0.0])
        dim = (0.3, 0.385, 0.4)
        angle = radians(10.)
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        Iz = ((dim[2]**2)/12.)
        It = np.array([ [Iz + Iy, 0.0, 0.0],
                        [0.0, Ix + Iz, 0.0],
                        [0.0, 0.0, Ix + Iy] ])
        mass = 50.0
        # rotational axis and versors
        ax, ay, az = axis = np.array([1., 1., 1.])
        mod = np.sqrt((ax**2)+(ay**2)+(az**2))
        axis_ver = (axis/mod)
        # shape
        caisson = mst.Cuboid(domain=domain3D, dim=dim, coords=[pos[0], pos[1], pos[2]])
        caisson.rotate(rot=angle, axis=axis)
        coords_system = caisson.coords_system
        caisson3D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain3D)      
        # rotational operator for inertia calculation on an arbitrary axis
        rotx, roty, rotz = np.dot(axis_ver, np.linalg.inv(coords_system))
        rot = np.array([ [(rotx**2), rotx*roty, rotx*rotz],
                         [roty*rotx, (roty**2), roty*rotz],
                         [rotz*rotx, rotz*roty, (rotz**2)] ])
        #inertia = np.einsum('ij,ij->', mass*It, rot)
        inertia = np.sum(mass*It*rot)
        # testing from BodyDynamics
        c3d = caisson3D
        c3d.nd = 3
        c3d.mass = mass
        c3d.It = It
        c3d.coords_system = coords_system
        I = c3d.getInertia(vec=axis)
        npt.assert_equal(I, inertia)
示例#26
0
    def testFrictionModule(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        #########################
        # 1st case              #
        #########################
        # When sliding is true and caisson already experiences plastic displacements

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(dt/substeps)
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == True. dynamic sign and dynamic friction
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.001, 0.001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps)
        c2d.sliding, sign, m = True, sign_dynamic, m_dynamic
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = (Fy - Cy*vy0 - Ky*uy0) / mass
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx+Ftan
        Kx, Cx = 0.0, 0.0
        ax0, az0 = (Fh - Cx*vx0 - Kx*ux0) / mass , (Fz - Cz*vz0 - Kz*uz0) / mass
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt) 
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 0.0, 1.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
         

        #########################
        # 2nd case              #
        #########################
        # When sliding is false but the caisson starts to experience sliding motion

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(dt/substeps)
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == False. static sign and static friction
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.001, 0.001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps)
        c2d.sliding, sign, m = False, sign_static, m_static
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = (Fy - Cy*vy0 - Ky*uy0) / mass
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx+Ftan
        Kx, Cx = 0.0, 0.0
        ax0, az0 = (Fh - Cx*vx0 - Kx*ux0) / mass , (Fz - Cz*vz0 - Kz*uz0) / mass
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt)
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 0.0, 1.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
         

        #########################
        # 3rd case              #
        #########################
        # When caisson experiences vibration motion

        # parameters
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        dt, substeps = 0.001, 20  
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.CaissonBody(shape=caisson, substeps=substeps)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        dt_sub = c2d.dt_sub = float(dt/substeps)
        Ix = ((dim[0]**2)/12.)
        Iy = ((dim[1]**2)/12.)
        It = Ix + Iy 
        mass = 50.0
        c2d.mass, c2d.It = mass, It
        K = Kx, Ky, Kz = [200000., 250000., 0.0]
        C = Cx, Cy, Cz = [2000., 4000., 0.0]
        c2d.Kx, c2d.Ky, c2d.Kz, c2d.Cx, c2d.Cy, c2d.Cz =  Kx, Ky, Kz, Cx, Cy, Cz
        c2d.substeps, c2d.dt, c2d.acceleration = substeps, dt, c2d.getAcceleration()
        m_static, m_dynamic = 0.6, 0.4
        c2d.setFriction(friction=True, m_static=m_static, m_dynamic=m_dynamic, tolerance=0.000001, grainSize=0.02)
        # sliding == False. static sign and static friction. Kx and Cx different from 0!
        F = Fx, Fy, Fz = np.array([200., -300., 0.0])
        disp = np.array([0.00001, 0.00001, 0.0])
        init_barycenter, last_position, last_velocity = pos, pos+disp, np.array([0.05, 0.07, 0.0])
        c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0]           
        c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity  
        eps = 10.**-30
        sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps)
        c2d.sliding, sign, m = False, sign_static, m_static
        # vertical calculation and frictional force        
        uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1]
        ay0 = (Fy - Cy*vy0 - Ky*uy0) / mass
        uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False)
        Rx = -Kx*(last_position[0]-init_barycenter[0])
        Ry = -Ky*uy
        Ftan = -sign*abs(Ry)*m
        if Ftan == 0.0: 
            Ftan = -sign*abs(Fy)*m
        # runge-kutta calculation
        c2d.scheme = 'Runge_Kutta'
        ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2]
        vx0, vz0 = last_velocity[0], last_velocity[2]
        Fh = Fx        
        ax0, az0 = (Fh - Cx*vx0 - Kx*ux0) / mass , (Fz - Cz*vz0 - Kz*uz0) / mass
        ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True)
        uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False)
        # bodydynamics calculation
        c2d.friction_module(dt)
        # tests
        npt.assert_equal(c2d.ux, ux)
        EL1, PL1 = 1.0, 0.0 # elastic and plastic motion parameters
        npt.assert_equal(c2d.EL, EL1)
        npt.assert_equal(c2d.PL, PL1)
示例#27
0
    def testGetInertia(self):
        from proteus import Domain  
        from proteus import SpatialTools as st    
        from proteus.mprans import SpatialTools as mst
        from proteus.mprans import BodyDynamics as bd   

        # 2d case
        domain2D = Domain.PlanarStraightLineGraphDomain()
        pos = np.array([1.0, 1.0, 0.0])
        dim = (0.3, 0.385)
        caisson = mst.Rectangle(domain=domain2D, dim=dim, coords=[pos[0], pos[1]])
        caisson2D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain2D)      
        c2d = caisson2D
        c2d.nd = 2
        Ix = (old_div((dim[0]**2),12.))
        Iy = (old_div((dim[1]**2),12.))
        It = Ix + Iy 
        mass = 50.0
        I1 = It*mass
        c2d.mass = mass
        c2d.It = It
        I2 = c2d.getInertia()
        npt.assert_equal(I1, I2)

        # 3d case
        pos, dim, caisson = [], [], []
        domain3D = Domain.PiecewiseLinearComplexDomain()
        pos = np.array([0.0, 0.0, 0.0])
        dim = (0.3, 0.385, 0.4)
        angle = radians(10.)
        Ix = (old_div((dim[0]**2),12.))
        Iy = (old_div((dim[1]**2),12.))
        Iz = (old_div((dim[2]**2),12.))
        It = np.array([ [Iz + Iy, 0.0, 0.0],
                        [0.0, Ix + Iz, 0.0],
                        [0.0, 0.0, Ix + Iy] ])
        mass = 50.0
        # rotational axis and versors
        ax, ay, az = axis = np.array([1., 1., 1.])
        mod = np.sqrt((ax**2)+(ay**2)+(az**2))
        axis_ver = (old_div(axis,mod))
        # shape
        caisson = mst.Cuboid(domain=domain3D, dim=dim, coords=[pos[0], pos[1], pos[2]])
        caisson.rotate(rot=angle, axis=axis)
        coords_system = caisson.coords_system
        caisson3D = bd.RigidBody(shape=caisson)
        mst.assembleDomain(domain3D)      
        # rotational operator for inertia calculation on an arbitrary axis
        rotx, roty, rotz = np.dot(axis_ver, np.linalg.inv(coords_system))
        rot = np.array([ [(rotx**2), rotx*roty, rotx*rotz],
                         [roty*rotx, (roty**2), roty*rotz],
                         [rotz*rotx, rotz*roty, (rotz**2)] ])
        #inertia = np.einsum('ij,ij->', mass*It, rot)
        inertia = np.sum(mass*It*rot)
        # testing from BodyDynamics
        c3d = caisson3D
        c3d.nd = 3
        c3d.mass = mass
        c3d.It = It
        c3d.coords_system = coords_system
        I = c3d.getInertia(vec=axis)
        npt.assert_equal(I, inertia)
示例#28
0
tank.BC['y+'].setAtmosphere()

rect.BC['x+'].setNoSlip()
rect.BC['x-'].setNoSlip()
rect.BC['y+'].setNoSlip()
rect.BC['y-'].setNoSlip()

# CHRONO

system = crb.ProtChSystem(gravity=np.array([0.,-9.81,0.]))
body = crb.ProtChBody(system=system, shape=rect)
body.ChBody.SetMass(500.)
body.ChBody.SetBodyFixed(True)  # fixing body

# OTHER PARAMS
st.assembleDomain(domain)

max_flag = max(domain.vertexFlags+domain.segmentFlags+domain.facetFlags)
flags_rigidbody = np.zeros(max_flag+1, dtype='int32')
for key in rect.boundaryTags_global:
    flags_rigidbody[rect.boundaryTags_global[key]] = 1


from proteus.ctransportCoefficients import smoothedHeaviside
from proteus.ctransportCoefficients import smoothedHeaviside_integral
from proteus.default_n import *

addedMass = True
movingDomain=True
checkMass=False
applyCorrection=True
示例#29
0
# define length and width of rectangle
length = 40.0
width = 10.0

# define vertices and segments
my_vertices = [[0.0, 0.0], [length, 0.0], [length, width], [0.0, width]]
my_segments = [[0, 1], [1, 2], [2, 3], [3, 0]]

# boundary tags dictionary
bt = {'inflow': 1, 'reflecting': 99}
my_vertexFlags = [bt['inflow'], bt['reflecting'], bt['reflecting'], bt['inflow']]
my_segmentFlags = [bt['reflecting'], bt['reflecting'], bt['reflecting'], bt['inflow']]

my_customShape = st.CustomShape(domain, boundaryTags=bt,
                           vertices=my_vertices, vertexFlags=my_vertexFlags,
                           segments=my_segments, segmentFlags=my_segmentFlags)

# define cylindrical obstacle. boundaryTag value is set to 99-2 here because of
# weird 'start_flag' issue in `_assembleGeometry` in SpatialTools.py
center_x = 10.0
center_y = 5.0
my_circle = st.Circle(domain=domain,
                      radius=1.,
                      barycenter=[center_x, center_y],
                      coords=[center_x, center_y],
                      nPoints=20,
                      boundaryTag={'reflecting': 99-2})

# set obstacle to be hole and set boundary tag to reflecting
my_circle.setHoles([[center_x, center_y]])
示例#30
0

#  ____                        _
# |  _ \  ___  _ __ ___   __ _(_)_ __
# | | | |/ _ \| '_ ` _ \ / _` | | '_ \
# | |_| | (_) | | | | | | (_| | | | | |
# |____/ \___/|_| |_| |_|\__,_|_|_| |_|
# Domain
# All geometrical options go here (but not mesh options)

domain = Domain.PiecewiseLinearComplexDomain()

# ----- SHAPES ----- #

# TANK
tank = st.Tank3D(domain, tank_dim)

# CAISSON
radius = 0.1
caisson = st.Cuboid(domain,
                    dim=[2*radius, 2*radius, 2*radius],
                    coords=(tank_dim[0]/2., tank_dim[1]/2., water_level+radius/10.),
                    barycenter=(tank_dim[0]/2., tank_dim[1]/2., water_level+radius/10.))
caisson.setHoles([caisson.barycenter])
caisson.holes_ind = np.array([0])
# let gmsh know that the caisson is IN the tank
tank.setChildShape(caisson, 0)


#  ____                        _                   ____                _ _ _   _
# | __ )  ___  _   _ _ __   __| | __ _ _ __ _   _ / ___|___  _ __   __| (_) |_(_) ___  _ __  ___
示例#31
0
# | | | |/ _ \| '_ ` _ \ / _` | | '_ \
# | |_| | (_) | | | | | | (_| | | | | |
# |____/ \___/|_| |_| |_|\__,_|_|_| |_|
# Domain
# All geometrical options go here (but not mesh options)

domain = Domain.PlanarStraightLineGraphDomain()

# ----- SHAPES ----- #

# TANK
tank_dim = np.array([3., 10.])
tank_x = tank_dim[0]
tank_y = tank_dim[1]
water_level=tank_y*2
tank = st.Tank2D(domain, [tank_x, tank_y])

#  ____                        _                   ____                _ _ _   _
# | __ )  ___  _   _ _ __   __| | __ _ _ __ _   _ / ___|___  _ __   __| (_) |_(_) ___  _ __  ___
# |  _ \ / _ \| | | | '_ \ / _` |/ _` | '__| | | | |   / _ \| '_ \ / _` | | __| |/ _ \| '_ \/ __|
# | |_) | (_) | |_| | | | | (_| | (_| | |  | |_| | |__| (_) | | | | (_| | | |_| | (_) | | | \__ \
# |____/ \___/ \__,_|_| |_|\__,_|\__,_|_|   \__, |\____\___/|_| |_|\__,_|_|\__|_|\___/|_| |_|___/
#                                           |___/
# Boundary Conditions


#tank.BC['y+'].setFreeSlip()
tank.BC['y+'].setAtmosphere()
#tank.BC['y-'].setFreeSlip()
#tank.BC['x+'].setFreeSlip()
#tank.BC['x-'].setFreeSlip()
示例#32
0
pro_wl = 0.5
g = np.array([0., 0., -9.81])
he = opts.he
# ****************** #
# ***** GAUGES ***** #
# ****************** #

# *************************** #
# ***** DOMAIN AND MESH ***** #
# *************************** #
from proteus.mprans import SpatialTools as st

domain = Domain.PiecewiseLinearComplexDomain()
domain2 = Domain.PiecewiseLinearComplexDomain()

SG = st.ShapeSTL(domain2, 'SG_full_2.stl')

boundaries = ['gate', 'left', 'right', 'bottom', 'top', 'front', 'back']
boundaryTags = dict([(key, i + 1) for (i, key) in enumerate(boundaries)])

boundaryOrientations = {
    'gate': np.array([-1., 0., 0.]),
    'left': np.array([-1., 0., 0.]),
    'right': np.array([+1., 0., 0.]),
    'bottom': np.array([0., 0., -1.]),
    'top': np.array([0., 0., +1.]),
    'front': np.array([0., +1., 0.]),
    'back': np.array([0., -1., 0.]),
}

facetFlags = SG.facetFlags.tolist()
示例#33
0
    domain.MeshOptions.nny = 2 * refinement + 1
elif opts.structured:
    domain.MeshOptions.nnx = 4 * refinement
    domain.MeshOptions.nny = 2 * refinement

twoLayer = opts.twoLayer
domain.porosityTypes = np.array([1.0, 1.0, 1.0], 'd')
domain.dragAlphaTypes = np.array([0.0, 0.0, 0.0], 'd')
domain.dragBetaTypes = np.array([0.0, 0.0, 0.0], 'd')
domain.epsFact_porous = np.array([0.0, 0.0, 0.0], 'd')
if twoLayer:
    domain.porosityTypes[2] = 0.3
    domain.dragAlphaTypes[2] = 1.0e8
    domain.dragBetaTypes[2] = 1.0e8

st.assembleDomain(domain)

if opts.openTop is True:
    tank.BC['y+'].setAtmosphere()
else:
    tank.BC['y+'].setFreeSlip()
tank.BC['y-'].setFreeSlip()
tank.BC['x+'].setFreeSlip()
tank.BC['x-'].setFreeSlip()

#  ___       _ _   _       _    ____                _ _ _   _
# |_ _|_ __ (_) |_(_) __ _| |  / ___|___  _ __   __| (_) |_(_) ___  _ __  ___
#  | || '_ \| | __| |/ _` | | | |   / _ \| '_ \ / _` | | __| |/ _ \| '_ \/ __|
#  | || | | | | |_| | (_| | | | |__| (_) | | | | (_| | | |_| | (_) | | | \__ \
# |___|_| |_|_|\__|_|\__,_|_|  \____\___/|_| |_|\__,_|_|\__|_|\___/|_| |_|___/
# Initial Conditions
示例#34
0
rho_0 = 1000.
nu_0 = 1.004e-6
rho_1 = 1.205
nu_1 = 1.500e-5
sigma_01 = 0.0
g = [0., 0., -9.81]
he = 2.5
water_level = 2.5

# GEOMETRY

domain = Domain.PiecewiseLinearComplexDomain()
nd = 3
tank_dim = [5., 5., 5.]
tank = st.Tank3D(domain, dim=tank_dim)
rect = st.Cuboid(domain,
                 dim=[1., 1., 1.],
                 coords=[
                     old_div(tank_dim[0], 2.),
                     old_div(tank_dim[1], 2.),
                     old_div(tank_dim[2], 2.)
                 ])
rect.setHoles(holes=np.array([rect.coords]))

domain.MeshOptions.he = he
# BOUNDARY CONDITIONS

tank.BC['x+'].setNoSlip()
tank.BC['x-'].setNoSlip()
tank.BC['y-'].setNoSlip()
示例#35
0
# tank options
waterLevel = opts.water_level
tank_dim = opts.tank_dim
tank_sponge = opts.tank_sponge

# ----- DOMAIN ----- #

domain = Domain.PlanarStraightLineGraphDomain()

# refinement
smoothing = opts.he * 3.

# ----- TANK ------ #

tank = st.Tank2D(domain, tank_dim)

# ----- GENERATION / ABSORPTION LAYERS ----- #

tank.setSponge(x_n=tank_sponge[0], x_p=tank_sponge[1])
dragAlpha = 5. * omega / 1e-6

if opts.generation:
    tank.setGenerationZones(x_n=True,
                            waves=wave,
                            dragAlpha=dragAlpha,
                            smoothing=smoothing)
if opts.absorption:
    tank.setAbsorptionZones(x_p=True, dragAlpha=dragAlpha)

# ----- BOUNDARY CONDITIONS ----- #
示例#36
0
    ("K", 0.41, "von Karman coefficient for the turbulence model"),
    ("B", 5.57, "Wall coefficient for the turbulence model"),
    ("Cmu", 0.09, "Cmu coefficient for the turbulence model"),
    # simulation options
    ('duration', 10., 'Simulation duration'),
    ('dt_init', 0.001, 'Initial timestep'),
    ('dt_output', 0.1, 'time output interval'),
    ("he", 0.03, "Mesh size"),
    ("cfl", 0.5, "Target cfl")
])

#########################################
#domain
#########################################
domain = Domain.PlanarStraightLineGraphDomain()
tank = st.Tank2D(domain, dim=[opts.Lx, opts.Ly])
##################################
#turbulence calculations
##################################
# Reynodls
Re0 = opts.U[0] * opts.Ly / opts.nu
# Skin friction and friction velocity for defining initial shear stress at the wall
cf = 0.045 * (Re0**(-1. / 4.))
Ut = opts.U[0] * np.sqrt(cf / 2.)
kappaP = (Ut**2) / np.sqrt(opts.Cmu)
Y_ = opts.he
Yplus = Y_ * Ut / opts.nu
dissipationP = (Ut**3) / (0.41 * Y_)

# ke or kw
useRANS = opts.useRANS  # 0 -- None
示例#37
0
                        smoothing=smoothing)

#tank.setAbsorptionZones(x_p=True,
#			dragAlpha=dragAlpha,
#	                )

#####################     Shape Geometry & Characteristics    ###############################

# --- Circle
b = 2.0 * opts.radius
h = 2.0 * opts.radius

# --- Circle Setup
circle = st.Circle(domain=domain,
                   radius=opts.radius,
                   coords=(0.5, opts.tank_dim[1] / 2),
                   barycenter=(0.5, opts.tank_dim[1] / 2),
                   nPoints=opts.nPoints)

# --- Body properties setup
circle2D = bd.RigidBody(shape=circle)

circle2D.setMass(mass=opts.mass)
I = (3.14 * (opts.radius**4) / 2.) * opts.mass

circle2D.It = I / opts.mass / opts.width
circle2D.setConstraints(free_x=opts.free_x, free_r=opts.free_r)
circle2D.setNumericalScheme(scheme=opts.scheme)
circle2D.inputMotion(InputMotion=opts.InputMotion, At=opts.At, Tt=opts.Tt)
circle2D.setRecordValues(filename='circle2D', all_values=True)
示例#38
0
if opts.caisson2D:
    dimx = dimx
    dimy = dimy
    dim = (dimx, dimy)
    coords = [xc1 + b / 2.,
              hs + dimy / 2.]  # For bodyDimensions and barycenter
    VCG = dim[1] / 2.  # For barycenter
    width = opts.width  # The 3rd dimension
    mass = opts.mass  #kg
    volume = float(dimx * dimy * width)
    density = float(mass / volume)  #kg/m3
    I = mass * (dimx**2. + dimy**2.) / 12.
    # It=(dimx**2.+dimy**2.)/12.

    # --- Shape properties setup
    caisson = st.Rectangle(domain, dim=dim, coords=coords)
    caisson.vertices[0][0] = xc1
    caisson.vertices[0][1] = yc1
    caisson.vertices[1][0] = xc2
    caisson.vertices[1][1] = yc2

    # --- Body properties setup
    caisson2D = bd.CaissonBody(shape=caisson, substeps=20)
    free_x = (0.0, 0.0, 0.0)  # Translational DOFs
    free_r = (0.0, 0.0, 0.0)  # Rotational DOFs
    m_static = opts.m_static  # Static friction
    m_dynamic = opts.m_dynamic  # Dynamic friction
    if opts.movingDomain == True:
        free_x = (1.0, 1.0, 0.0)  # Translational DOFs
        if opts.overturning == True:
            free_r = (0.0, 0.0, 1.0)  # Rotational DOFs
示例#39
0
    1,
    1,
    2,
    3,
    4,
])

regions = [[0.1, 0.1]]

regionFlags = np.array([1])

tank = st.CustomShape(domain,
                      vertices=vertices,
                      vertexFlags=vertexFlags,
                      segments=segments,
                      segmentFlags=segmentFlags,
                      regions=regions,
                      regionFlags=regionFlags,
                      boundaryTags=boundaryTags,
                      boundaryOrientations=boundaryOrientations)

# ----- EXTRA BOUNDARY CONDITIONS ----- #
tank.BC['y+'].setAtmosphere()
tank.BC['y-'].setFreeSlip()
tank.BC['x-'].setTwoPhaseVelocityInlet(
    U=[opts.inflow_vel, 0., 0.],
    waterLevel=waterLine_y,
    smoothing=1.5 * opts.he,
)
tank.BC['x+'].setHydrostaticPressureOutletWithDepth(
    seaLevel=outflow_level,
# ----- DOMAIN ----- #

domain = Domain.PiecewiseLinearComplexDomain()

# ----- SHAPES ----- #

front = back = tank_sponge[0]
right = left = tank_sponge[1]
fbt = rlt = False
if front and back:
    fbt = True
if right and left:
    rlt = True

tank = st.Tank3D(domain, tank_dim)
tank.setSponge(front=front, back=back, right=right, left=left)
tank.setAbsorptionZones(front=fbt, back=fbt, right=rlt, left=rlt)

caisson3D = st.Cuboid(domain, dim=dim, coords=coords)
caisson3D.setRigidBody()
caisson3D.setBarycenter(barycenter)
caisson3D.setConstraints(free_x=free_x, free_r=free_r)
# mass is not real mass ---> inerta tensor provided and scaled by mass
mass = 15
caisson3D.setMass(mass)
caisson3D.It = np.array([[Ixx, 0., 0.], [0., Iyy, 0.], [0., 0., Izz]
                         ]) / caisson3D.mass
caisson3D.rotate(rotation_angle, rotation_axis)
caisson3D.setRecordValues(pos=True, rot=True, F=True, M=True)