コード例 #1
0
    def test_run(self):
        """ Test if cfd can run

        """

        path = os.path.join(os.path.dirname(__file__), "CFD_exampleFluid")

        cuds = CUDS(name='example_kratos_cfd_simulatiob')

        itime = api.IntegrationTime(name="cfd_integration_time")
        itime.time = 0.0001
        itime.step = 0.0025
        itime.final = 0.0075
        cuds.add([itime])

        cfd_utils = CFD_Utils()

        model_fluid = cfd_utils.read_modelpart(path)

        for model in [model_fluid]:
            cuds.add(list(model['datasets']))
            cuds.add(list(model['conditions']))
            cuds.add(list(model['materials']))
            cuds.add([model['pe']])

        # Create the simulation and run the problem
        sim = Simulation(cuds, "KRATOS_CFD", engine_interface=True)
        sim.run()
コード例 #2
0
    def test_run(self):
        """ Test if cfd can run

        """

        pathParticles = os.path.join(
            "/home/travis/build/simphony/simphony-kratos/simkratos/tests/dem",
            "3balls"
        )
        pathSolid = os.path.join(
            "/home/travis/build/simphony/simphony-kratos/simkratos/tests/dem",
            "3ballsDEM_FEM_boundary"
        )

        cuds = CUDS(name='example_kratos_dem_somulation')

        itime = api.IntegrationTime(name="dem_integration_time")
        itime.time = 0.0001
        itime.step = 0.001
        itime.final = 60 * itime.step
        cuds.add([itime])

        utils = DEM_Utils()

        print(pathParticles)

        model_particles = utils.read_modelpart_as_particles(pathParticles)
        model_solid = utils.read_modelpart_as_mesh(pathSolid)

        for model in [model_particles, model_solid]:
            cuds.add(list(model['datasets']))
            cuds.add(list(model['conditions']))
            cuds.add(list(model['materials']))
            cuds.add([model['pe']])

        sim = Simulation(cuds, "KRATOS_DEM", engine_interface=True)
        sim.run()
コード例 #3
0
        'pe': smp_pe,
    }


def abs_path(relPath):
    return os.path.join(os.path.dirname(os.path.abspath(__file__)), relPath)


# Path for the Kratos' MDPA
pathFluid = abs_path("fluid_prism")
pathParticles = abs_path("fibers_and_ballsDEM")

cuds = CUDS(name='Coupling')

# Integration time for the fluid solver:
CFDitime = api.IntegrationTime(name="CFD_Integration_time")
CFDitime.time = 0.0001
CFDitime.step = 0.005
CFDitime.final = 0.0125  # 1 Kratos Timesteps

# Integration time for the particle solver
DEMitime = api.IntegrationTime(name="DEM_Integration_time")
DEMitime.time = 0.0001
DEMitime.step = 5e-5
DEMitime.final = 0.0125  # 5 Kratos Timesteps

COUiTime = api.IntegrationTime(name="COU_Inetegration_time")

cuds.add([COUiTime])

# Utils are used to read an existing Kratos model as raw data so we can
コード例 #4
0
cuds.add([foam])

# use Herschel Bulkley viscosity model for aqueous foam
hb = api.HerschelBulkleyModel(name='foam_rheology')
hb.initial_viscosity = 0.01748
hb.relaxation_time = 0.0148
hb.linear_constant = 0.00268
hb.power_law_index = 0.5
hb.material = cuds.get_by_name('foam').uid
cfd.rheology_model = hb

cuds.add([cfd])

# time setting
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=0.3,
                               size=0.0001)
cuds.add([sim_time])

end = time.time()
print "Time spend in initialization: ", end - start

start = time.time()
# create computational mesh
mesh = foam_controlwrapper.create_block_mesh(tempfile.mkdtemp(), mesh_name,
                                             pipe_mesh.blockMeshDict)
end = time.time()
print "Time spend in blockmesh: ", end - start

start = time.time()
cuds.add([mesh])
コード例 #5
0
"""

import os

from simphony.api import CUDS, Simulation
from simphony.cuds.meta import api

from simkratos.CFD.kratos_CFD_utils import CFD_Utils

# Add the problem path to the script
path = os.path.join(os.path.dirname(__file__), "CFD_exampleFluid")

cuds = CUDS(name='example_fluid_name')

# Integration time:
itime = api.IntegrationTime(name="md_nve_integration_time")
itime.time = 0.0001
itime.step = 0.0025
itime.final = 0.0125  # 5 Kratos Timesteps
cuds.add([itime])

# Utils are used to read an existing Kratos model as raw data so we can
# initialize the correct simphony datasets. We can also use manualy written
# datasets.
cfd_utils = CFD_Utils()

# Reads kratos data so its interpretable by simphony
model_fluid = cfd_utils.read_modelpart(path)

# Add all datasets from the fluid to the CFD wrapper
for model in [model_fluid]:
コード例 #6
0
cuds.add([air])

# surface tension

st = api.SurfaceTensionRelation(material=[water, air],
                                surface_tension=72.86e-3)
cuds.add([st])

# free surface model

fsm = api.FreeSurfaceModel(name='vof')
cuds.add([fsm])

# time setting
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=0.5,
                               size=1.0e-5)
cuds.add([sim_time])

# solver parameters
sp = api.SolverParameter(name='solver_parameters')
sp.data[CUBA.MAXIMUM_COURANT_NUMBER] = 0.2
cuds.add([sp])

gm = api.GravityModel(name='gravitation')
gm.acceleration = (0, -9.81, 0)
cuds.add([gm])

# boundary conditions
vel_inlet = api.InletOutletVelocity((0, 0, 0), water, name='vel_inlet')
pres_inlet = api.ConstantPressureCondition(0.0, water, name='pres_inlet')
コード例 #7
0
    def setUp(self):

        case_name = "simplemeshIO"
        mesh_name = "simplemeshIO_mesh"

        cuds = CUDS(name=case_name)
        # physics model
        cfd = api.Cfd(name='default model')
        cuds.add([cfd])

        self.sim_time = api.IntegrationTime(name='simulation_time',
                                            current=0.0,
                                            final=1.0,
                                            size=0.5)
        cuds.add([self.sim_time])

        mat = api.Material(name='a_material')
        mat._data[CUBA.DENSITY] = 1.0
        mat._data[CUBA.DYNAMIC_VISCOSITY] = 1.0
        cuds.add([mat])

        vel_inlet = api.Dirichlet(mat, name='vel_inlet')
        vel_inlet._data[CUBA.VARIABLE] = CUBA.VELOCITY
        vel_inlet._data[CUBA.VELOCITY] = (0.1, 0, 0)
        pres_inlet = api.Neumann(mat, name='pres_inlet')
        pres_inlet._data[CUBA.VARIABLE] = CUBA.PRESSURE

        vel_outlet = api.Neumann(mat, name='vel_outlet')
        vel_outlet._data[CUBA.VARIABLE] = CUBA.VELOCITY
        pres_outlet = api.Dirichlet(mat, name='pres_outlet')
        pres_outlet._data[CUBA.VARIABLE] = CUBA.PRESSURE
        pres_outlet._data[CUBA.PRESSURE] = 0.0

        vel_walls = api.Dirichlet(mat, name='vel_walls')
        vel_walls._data[CUBA.VARIABLE] = CUBA.VELOCITY
        vel_walls._data[CUBA.VELOCITY] = (0, 0, 0)
        pres_walls = api.Neumann(mat, name='pres_walls')
        pres_walls._data[CUBA.VARIABLE] = CUBA.PRESSURE

        vel_frontAndBack = api.EmptyCondition(name='vel_frontAndBack')
        vel_frontAndBack._data[CUBA.VARIABLE] = CUBA.VELOCITY
        pres_frontAndBack = api.EmptyCondition(name='pres_frontAndBack')
        pres_frontAndBack._data[CUBA.VARIABLE] = CUBA.PRESSURE

        inlet = api.Boundary(name='inlet', condition=[vel_inlet, pres_inlet])
        walls = api.Boundary(name='walls', condition=[vel_walls, pres_walls])
        outlet = api.Boundary(name='outlet',
                              condition=[vel_outlet, pres_outlet])
        frontAndBack = api.Boundary(
            name='frontAndBack',
            condition=[vel_frontAndBack, pres_frontAndBack])

        cuds.add([inlet, walls, outlet, frontAndBack])

        corner_points = [(0.0, 0.0, 0.0), (5.0, 0.0, 0.0), (5.0, 5.0, 0.0),
                         (0.0, 5.0, 0.0), (0.0, 0.0, 1.0), (5.0, 0.0, 1.0),
                         (5.0, 5.0, 1.0), (0.0, 5.0, 1.0)]
        self.mesh_path = tempfile.mkdtemp()
        mesh = create_quad_mesh(self.mesh_path, mesh_name, corner_points, 5, 5,
                                5)
        cuds.add([mesh])
        self.cuds = cuds
        self.sim = Simulation(cuds,
                              'OpenFOAM',
                              engine_interface=EngineInterface.FileIO)
        self.mesh_in_cuds = self.cuds.get_by_name(mesh_name)
コード例 #8
0
from simkratos.DEM.kratos_DEM_utils import DEM_Utils


def abs_path(relPath):
    return os.path.join(os.path.dirname(os.path.abspath(__file__)), relPath)


# Path for the Kratos' MDPA
pathParticles = abs_path("3ballsDEM")
pathSolid = abs_path("3ballsDEM_FEM_boundary")

cuds = CUDS(name='example_kratos_dem_somulation')

# Integration time:
itime = api.IntegrationTime(name="dem_integration_time")
itime.time = 0.0001
itime.step = 0.001
itime.final = 60 * itime.step
cuds.add([itime])

# Utils are used to read an existing Kratos model as raw data so we can
# initialize the correct simphony datasets. We can also use manualy written
# datasets.
utils = DEM_Utils()

# Reads Kratos mpda as a simphony data.
model_particles = utils.read_modelpart_as_particles(pathParticles)
model_solid = utils.read_modelpart_as_mesh(pathSolid)

# Add all datasets from the particles to the DEM wrapper
コード例 #9
0
walls = api.Boundary(name='walls', condition=[vel_walls, pres_walls])
outlet = api.Boundary(name='outlet', condition=[vel_outlet, pres_outlet])

cuds.add([inlet, walls, outlet])

end = time.time()
print "Time spend in boundary settings: ", end - start

start = time.time()
sim = Simulation(cuds, 'OpenFOAM', engine_interface=EngineInterface.Internal)
end = time.time()
print "Time spend in Simulation initialization: ", end - start

# time setting
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=20,
                               size=1)
cuds.add([sim_time])

sim.run()

mesh_in_engine = cuds.get_by_name(mesh_name)

sm = api.MesoscopicStressModel(name='meso_stress_model')
cuds.add([sm])

cuds.remove('simulation_time')
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=1,
                               size=1)