Beispiel #1
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)
Beispiel #2
0
# Chrono

# SYSTEM

# create system
system = fsi.ProtChSystem()
# access chrono object
chsystem = system.getChronoObject()
# communicate gravity to system
# can also be set with:
# system.ChSystem.Set_G_acc(pychrono.ChVectorD(g[0], g[1], g[2]))
system.setGravitationalAcceleration(g)
# set maximum time step for system
system.setTimeStep(1e-4)

solver = pychrono.ChSolverMINRES()
chsystem.SetSolver(solver)

# BODY

# create floating body
body = fsi.ProtChBody(system=system)
# give it a name
body.setName(b'my_body')
# attach shape: this automatically adds a body at the barycenter of the caisson shape
body.attachShape(caisson)
# set 2D width (for force calculation)
body.setWidth2D(0.29)
# access chrono object
chbody = body.getChronoObject()
# impose constraints
    def __init__(self,
                 configuration,
                 visualization: bool = False,
                 output: Optional = None) -> None:
        # TODO a copy of the configuration is better
        self._conf = configuration
        self._visualization = visualization
        self._output = output
        self._app = None

        # TODO not sure about the meaning of theese two parameters, take them from the configuation
        chrono.ChCollisionInfo.SetDefaultEffectiveCurvatureRadius(1)
        chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.006)

        # TODO look into the parameters of the system
        # e.g. MinBounceSpeed, Gravity
        self._system = chrono.ChSystemSMC()

        if self._visualization:
            # TODO take the data path, the title, the dimension and do_[something] from the configuration
            chrono.SetChronoDataPath(
                "/home/gianluca/anaconda3/envs/chrono/share/chrono/data/")
            self._app = irr.ChIrrApp(
                self._system,
                "Artificial Skin",
                irr.dimension2du(1024, 768),
                do_fullscreen=False,
                do_shadows=True,
                do_antialias=True,
            )
            self._app.AddTypicalSky()
            self._app.AddTypicalLights()
            # TODO take the info for the came and lighs from the configuation
            self._app.AddTypicalCamera(irr.vector3df(-1, -1, 0),
                                       irr.vector3df(0, 0, 0))
            # TODO this has too many parameters and it is not that important
            self._app.AddLightWithShadow(
                irr.vector3df(1.5, 5.5, -2.5),
                irr.vector3df(0, 0, 0),
                3,
                2.2,
                7.2,
                40,
                512,
                irr.SColorf(1, 1, 1),
            )
            self._app.AddShadowAll()
            self._app.SetTimestep(0.004)

        self._make_sheets()
        self._make_sensors()
        # TODO make the load class -> it takes a node / pair of indexes and time and return the force
        self._add_forces()

        # TODO look at all the parameters of the solver and the stepper
        # TODO consider also mkl.ChSolverMKL
        # TODO take the parameters from the configuration
        self._solver = chrono.ChSolverMINRES()
        self._system.SetSolver(self._solver)
        self._solver.SetMaxIterations(1000)
        self._solver.SetTolerance(1e-12)
        self._solver.EnableDiagonalPreconditioner(True)
        self._solver.SetVerbose(
            False)  # don't take this from the configuration

        # HHT implicit integrator for II order systems, adaptive
        # TODO take the parameters from the configuaration
        self._stepper = chrono.ChTimestepperHHT(self._system)
        self._system.SetTimestepper(self._stepper)
        self._stepper.SetAlpha(-0.2)
        self._stepper.SetMaxiters(100)
        self._stepper.SetAbsTolerances(1e-5)
        self._stepper.SetMode(chrono.ChTimestepperHHT.POSITION)
        self._stepper.SetScaling(True)

        # TODO from configuarion
        # length of the simulation
        self._life = 5  # seconds
Beispiel #4
0
my_mesh.AddAsset(mvisualizemeshC)

mvisualizemeshD = fea.ChVisualizationFEAmesh(my_mesh)
mvisualizemeshD.SetFEMglyphType(fea.ChVisualizationFEAmesh.E_GLYPH_NONE)
mvisualizemeshD.SetFEMdataType(fea.ChVisualizationFEAmesh.E_PLOT_SURFACE)
mvisualizemeshD.SetSymbolsScale(1)
mvisualizemeshD.SetColorscaleMinMax(-0.5, 5)
mvisualizemeshD.SetZbufferHide(False)
my_mesh.AddAsset(mvisualizemeshD)

application.AssetBindAll()
application.AssetUpdateAll()

# Perform a dynamic time integration:

solver = chrono.ChSolverMINRES()
my_system.SetSolver(solver)
solver.SetMaxIterations(1000)
solver.SetTolerance(1e-10)
solver.EnableDiagonalPreconditioner(True)
solver.SetVerbose(False)

mystepper = chrono.ChTimestepperHHT(my_system)
my_system.SetTimestepper(mystepper)
mystepper.SetAlpha(-0.2)
mystepper.SetMaxiters(100)
mystepper.SetAbsTolerances(1e-5)
mystepper.SetMode(chrono.ChTimestepperHHT.POSITION)
mystepper.SetScaling(True)
application.SetTimestep(0.004)