def test_get_named_cuds_component(self): c = CUDS() c.add([self.named_cuds_1]) self.assertEqual(c.get_by_name(self.named_cuds_1.name), self.named_cuds_1) self.assertEqual(c.get(self.named_cuds_1.uid), self.named_cuds_1)
def test_add_named_dataset(self): ps = Particles('my particles') ps.add([Particle(), Particle()]) c = CUDS() c.add([ps]) self.assertEqual(c.get_by_name(ps.name), ps) self.assertRaises(ValueError, c.add, [ps])
def test_add_named_dataset(self): ps = Particles('my particles') ps.add([Particle(), Particle()]) c = CUDS() c.add([ps]) self.assertEqual(c.get_by_name(ps.name), ps) self.assertRaises(ValueError, c.add, [ps])
def test_get_named_cuds_component(self): c = CUDS() c.add([self.named_cuds_1]) self.assertEqual(c.get_by_name(self.named_cuds_1.name), self.named_cuds_1) self.assertEqual(c.get(self.named_cuds_1.uid), self.named_cuds_1)
cfd.turbulence_model = api.LaminarFlowModel(name='laminar') cfd.compressibility_model = api.IncompressibleFluidModel(name='incompressible') # material foam = api.Material(name='foam') foam.data[CUBA.DENSITY] = 250.0 foam.data[CUBA.DYNAMIC_VISCOSITY] = 4.37 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()
cfd.turbulence_model = api.LaminarFlowModel(name='laminar') cfd.compressibility_model = api.IncompressibleFluidModel(name='incompressible') # material foam = api.Material(name='foam') foam.data[CUBA.DENSITY] = 250.0 foam.data[CUBA.DYNAMIC_VISCOSITY] = 4.37 cuds.add([foam]) # use Herschel Bulkley viscosity model for aqueous foam hb = api.HerschelBulkleyModel(name='foam_rheology') hb.initial_viscosity = 0.01748 * foam.data[CUBA.DENSITY] hb.relaxation_time = 0.0148 * foam.data[CUBA.DENSITY] hb.linear_constant = 0.00268 * foam.data[CUBA.DENSITY] 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=1000, size=1) cuds.add([sim_time]) sol_par = api.SolverParameter(name='steady_state') sol_par.data[CUBA.STEADY_STATE] = True cuds.add([sol_par])
# materials sludge = api.Material(name='sludge') sludge.data[CUBA.DENSITY] = 1900.0 sludge.data[CUBA.DYNAMIC_VISCOSITY] = 0.01 cuds.add([sludge]) water = api.Material(name='water') water.data[CUBA.DENSITY] = 1000.0 water.data[CUBA.DYNAMIC_VISCOSITY] = 1.0e-3 cuds.add([water]) # mixture model mm = api.MixtureModel(name='mixture') mm.disperse = cuds.get_by_name('sludge').uid cuds.add([mm]) # use Bingham plastic for sludge rheology model bp = api.BinghamPlasticModel(name='sludge_rheology') bp.linear_constant = (0.00023143, 0.0005966) bp.power_law_index = (179.26, 1050.8) bp.maximum_viscosity = 10.0 bp.material = cuds.get_by_name('sludge').uid # water is Newtonian so no need to add that to rheology models cfd.rheology_model = bp cuds.add([cfd]) sm = api.StandardStressModel(name='standard_stress_model')
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]) sim = Simulation(cuds, 'OpenFOAM', engine_interface=EngineInterface.FileIO) sim.run() average_pressure = 0.0 mesh_in_engine = cuds.get_by_name(mesh_name) print "working directory ", mesh_in_engine.path for cell in mesh_in_engine.get_boundary_cells(inlet.name): average_pressure += cell.data[CUBA.PRESSURE] average_pressure /= len(mesh_in_engine._boundaries[inlet.name]) print "Average pressure on " + inlet.name + ": ", average_pressure @mayavi2.standalone def view(): from mayavi.modules.surface import Surface from simphony_mayavi.sources.api import CUDSSource
# materials sludge = api.Material(name='sludge') sludge.data[CUBA.DENSITY] = 1900.0 sludge.data[CUBA.DYNAMIC_VISCOSITY] = 0.01 cuds.add([sludge]) water = api.Material(name='water') water.data[CUBA.DENSITY] = 1000.0 water.data[CUBA.DYNAMIC_VISCOSITY] = 1.0e-3 cuds.add([water]) # mixture model mm = api.MixtureModel(name='mixture') mm.disperse = cuds.get_by_name('sludge').uid cuds.add([mm]) # use Bingham plastic for sludge rheology model bp = api.BinghamPlasticModel(name='sludge_rheology') bp.linear_constant = (0.00023143, 0.0005966) bp.power_law_index = (179.26, 1050.8) bp.maximum_viscosity = 10.0 bp.material = cuds.get_by_name('sludge').uid # water is Newtonian so no need to add that to rheology models cfd.rheology_model = bp cuds.add([cfd]) sm = api.StandardStressModel(name='standard_stress_model')
def test_add_named_cuds_component(self): c = CUDS() self.assertIsNone(c.add([self.named_cuds_1])) self.assertEqual(c.get_by_name(self.named_cuds_1.name), self.named_cuds_1)
inlet = api.Boundary(name='inlet', condition=[vel_inlet, pres_inlet, vf_inlet]) walls = api.Boundary(name='walls', condition=[vel_walls, pres_walls, vf_walls]) atm = api.Boundary(name='atmosphere', condition=[vel_atm, pres_atm, vf_atm]) frontAndBack = api.Boundary(name='frontAndBack', condition=[vel_frontAndBack, pres_frontAndBack, vf_frontAndBack]) cuds.add([inlet, walls, atm, frontAndBack]) # create mesh mesh = foam_controlwrapper.create_block_mesh(tempfile.mkdtemp(), mesh_name, tube_mesh.blockMeshDict) cuds.add([mesh]) mesh_in_cuds = cuds.get_by_name(mesh_name) start = time.time() updated_cells = [] zero_water = api.PhaseVolumeFraction(water, 0) zero_air = api.PhaseVolumeFraction(air, 0) one_water = api.PhaseVolumeFraction(water, 1) one_air = api.PhaseVolumeFraction(air, 1) # initial state. In VOF only one velocity and pressure field # for cell in mesh_in_cuds._iter_cells_parallell(): for cell in mesh_in_cuds.iter(item_type=CUBA.CELL): ymid = sum(mesh_in_cuds._get_point(puid).coordinates[1] for puid in cell.points) ymid /= sum(1.0 for _ in cell.points)
def test_add_named_cuds_component(self): c = CUDS() self.assertIsNone(c.add([self.named_cuds_1])) self.assertEqual(c.get_by_name(self.named_cuds_1.name), self.named_cuds_1)