Esempio n. 1
0
    def testSetterGetter(self):
        g = np.array([0., 0., -9.81])
        system = fsi.ProtChSystem()
        system.setGravitationalAcceleration(g)
        g0 = system.getGravitationalAcceleration()
        npt.assert_almost_equal(g0, g)

        mesh = fsi.ProtChMesh(system)
        mesh.getChronoObject()

        body = fsi.ProtChBody(system)
        # position
        pos = np.array([1., 2., 3.])
        body.setPosition(pos)
        pos0 = body.getPosition()
        npt.assert_almost_equal(pos0, pos)
        # inertia
        inertia = np.array([[1., 4., 5.], [4., 2., 6.], [5., 6., 3.]])
        inertiaXX = np.array([inertia[0, 0], inertia[1, 1], inertia[2, 2]])
        inertiaXY = np.array([inertia[0, 1], inertia[0, 2], inertia[1, 2]])
        body.setInertiaXX(inertiaXX)
        # inertiaXX0 = body.getInertiaXX()
        body.setInertiaXY(inertiaXY)
        # inertiaXY0 = body.getInertiaXY()
        inertia0 = body.getInertia()
        # npt.assert_almost_equal(inertiaXX0, inertiaXX)
        # npt.assert_almost_equal(inertiaXY0, inertiaXY)
        npt.assert_almost_equal(inertia0, inertia)
        # mass
        mass = 10.2
        body.setMass(mass)
        mass0 = body.getMass()
        npt.assert_almost_equal(mass0, mass)
Esempio n. 2
0
    def testHangingCableANCF(self):
        g = np.array([0., 0., -9.81])
        system = fsi.ProtChSystem()
        system.ChSystem.Set_G_acc(chrono.ChVectorD(g[0], g[1], g[2]))
        system.setTimeStep(1e-1)

        # timestepper = chrono.ChTimestepperEulerImplicitLinearized()
        # system.ChSystem.SetTimestepper(timestepper)
        solver = chrono.ChSolverMINRES()
        system.ChSystem.SetSolver(solver)
        solver.SetMaxIterations(100)
        solver.EnableWarmStart(True)
        solver.EnableDiagonalPreconditioner(True)
        solver.SetVerbose(True)
        system.ChSystem.SetSolverForceTolerance(1e-10)
        system.ChSystem.SetSolverMaxIterations(100)
        mesh = fsi.ProtChMesh(system)
        L = np.array([5.])
        nb_elems = np.array([3])
        d = np.array([1e-3])
        rho = np.array([1000.])
        E = np.array([1e10])
        cable_type = b"CableANCF"
        fairlead_body = fsi.ProtChBody(system)
        fairlead_body.ChBody.SetBodyFixed(True)
        mooring = fsi.ProtChMoorings(system=system,
                                     mesh=mesh,
                                     length=L,
                                     nb_elems=nb_elems,
                                     d=d,
                                     rho=rho,
                                     E=E,
                                     beam_type=cable_type)
        mooring.external_forces_manual = True  # tri: should work without this line
        # vertical cable
        mooring.setNodesPositionFunction(lambda s: np.array([0., 0., s]),
                                         lambda s: np.array([0., 0., 1.]))
        mooring.setNodesPosition()
        mooring.buildNodes()
        mooring.attachBackNodeToBody(fairlead_body)
        system.calculate_init()
        system.calculate(0.5)
        T = mooring.getTensionBack()
        strain = mooring.getNodesTension(eta=1.)[-1] * np.pi * d**2 / 4 * E
        T_sol = -np.ones(3) * g * rho * (np.pi * d**2 / 4. * L)
        npt.assert_almost_equal(-T, T_sol)
Esempio n. 3
0
                   floor=True)
cat1.computeSolution()
cat2.computeSolution()

# ANCHOR

# arbitrary body fixed in space
body2 = fsi.ProtChBody(system)
body2.barycenter0 = np.zeros(3)
# fix anchor in space
body2.ChBody.SetBodyFixed(True)

# MESH

# initialize mesh that will be used for cables
mesh = fsi.ProtChMesh(system)

# FEM CABLES

# moorings line 1
m1 = fsi.ProtChMoorings(system=system,
                        mesh=mesh,
                        length=np.array([L]),
                        nb_elems=np.array([nb_elems]),
                        d=np.array([d]),
                        rho=np.array([dens]),
                        E=np.array([E]))
m1.setName(b'mooring1')
# send position functions from catenary to FEM cable
m1.setNodesPositionFunction(cat1.s2xyz, cat1.ds2xyz)
# sets node positions of the cable