コード例 #1
0
ファイル: run_flow.py プロジェクト: svn2github/Escript
def run(dom, stream):
    constraints=VectorConstrainerOverBox()
    constraints.domain=Link(dom)
    constraints.left=[1,0,0]
    constraints.right=[1,0,0]
    constraints.top=[0,1,0]
    constraints.bottom=[0,1,0]
    constraints.front=[0,0,1]
    constraints.back=[0,0,1]

    sqe=Sequencer()
    sqe.dt_max=0.5
    sqe.t_end=1.

    source=EvaluateExpression()
    source.domain=Link(dom)
    source.t=Link(sqe)
    source.expression=["t","t"]

    flow=SteadyIncompressibleFlow()
    flow.domain=Link(dom,"domain")
    flow.internal_force=Link(source,"out")
    flow.location_prescribed_velocity=Link(constraints,"location_of_constraint")
    flow.prescribed_velocity=[0.,0.]

    ptest=Probe()
    ptest.expression="(x[0]+x[1]-1.)*t"
    ptest.t=Link(sqe)
    ptest.value=Link(flow,"pressure")

    s=Simulation([sqe,constraints,Simulation([flow],debug=True),ptest],debug=True)
    s.writeXML(stream)
    s.run()
コード例 #2
0
def run(dom, stream):
    constraints=VectorConstrainerOverBox()
    constraints.domain=Link(dom)
    constraints.left=[1,0,0]
    constraints.right=[1,0,0]
    constraints.top=[0,1,0]
    constraints.bottom=[0,1,0]
    constraints.front=[0,0,1]
    constraints.back=[0,0,1]

    sqe=Sequencer()
    sqe.dt_max=0.5
    sqe.t_end=1.

    source=EvaluateExpression()
    source.domain=Link(dom)
    source.t=Link(sqe)
    source.expression=["t","t"]

    flow=SteadyIncompressibleFlow()
    flow.domain=Link(dom,"domain")
    flow.internal_force=Link(source,"out")
    flow.location_prescribed_velocity=Link(constraints,"location_of_constraint")
    flow.prescribed_velocity=[0.,0.]

    ptest=Probe()
    ptest.expression="(x[0]+x[1]-1.)*t"
    ptest.t=Link(sqe)
    ptest.value=Link(flow,"pressure")

    s=Simulation([sqe,constraints,Simulation([flow],debug=True),ptest],debug=True)
    s.writeXML(stream)
    s.run()
コード例 #3
0
def run(dom, stream):
    temp_val = InterpolateOverBox()
    temp_val.domain = Link(dom, "domain")
    temp_val.value_left_bottom_front = 1.
    temp_val.value_right_bottom_front = 1.
    temp_val.value_left_top_front = 0.
    temp_val.value_right_top_front = 0.
    temp_val.value_left_bottom_back = 1.
    temp_val.value_right_bottom_back = 1.
    temp_val.value_left_top_back = 0.
    temp_val.value_right_top_back = 0.

    temp_constraints = ScalarConstrainerOverBox()
    temp_constraints.domain = Link(dom)
    temp_constraints.top = 1
    temp_constraints.bottom = 1

    vel_constraints = VectorConstrainerOverBox()
    vel_constraints.domain = Link(dom)
    vel_constraints.left = [1, 0, 0]
    vel_constraints.right = [1, 0, 0]
    vel_constraints.top = [0, 1, 0]
    vel_constraints.bottom = [0, 1, 0]
    vel_constraints.front = [0, 0, 1]
    vel_constraints.back = [0, 0, 1]

    mat = SimpleEarthModel()
    mat.density0 = 1.
    mat.viscocity0 = 1.
    mat.rayleigh_number = 10000.
    mat.alpha = 0.001

    temp = TemperatureAdvection(debug=True)
    temp.domain = Link(dom)
    temp.density = Link(mat, "density0")
    temp.heat_capacity = Link(mat, "heat_capacity")
    temp.location_fixed_temperature = Link(temp_constraints,
                                           "location_of_constraint")
    temp.fixed_temperature = Link(temp_val, "out")
    temp.safety_factor = 0.01
    mat.temperature = Link(temp, "temperature")
    grav = GravityForce()
    grav.domain = Link(dom, "domain")
    grav.direction = [0., -1., 0.]
    grav.density = Link(mat, "density")
    grav.gravity = Link(mat, "gravity")

    vel = SteadyIncompressibleFlow(debug=True)
    vel.domain = Link(dom)
    vel.internal_force = Link(grav, "gravity_force")
    vel.viscosity = Link(mat, "viscosity")
    vel.location_prescribed_velocity = Link(vel_constraints,
                                            "location_of_constraint")
    vel.rel_tol = 1.e-6
    temp.velocity = Link(vel, "velocity")

    sq = Sequencer()
    sq.t_end = 0.001

    vis = WriteVTK()
    vis.t = Link(sq)
    vis.data0 = Link(temp, "temperature")
    vis.data1 = Link(vel, "velocity")
    vis.dt = 0.0001
    vis.filename = os.path.join(WORKDIR, "temp.vtu")

    per = GaussianProfile()
    per.domain = Link(dom)
    per.x_c = [0.5, 0.5, 0.5]
    per.A = 0.0001
    per.width = 0.01
    per.r = 0

    lc = LinearCombination()
    lc.f0 = 1.
    lc.v0 = Link(per, "out")
    lc.f1 = 1.
    lc.v1 = Link(temp_val, "out")
    temp.temperature = Link(lc, "out")

    s = Simulation([
        sq, vel_constraints, temp_constraints,
        Simulation([vel], debug=True), temp, vis
    ],
                   debug=True)
    s.writeXML(stream)
    s.run()
コード例 #4
0
# iob.value_right_top_front=[0.,0.]
# iob.value_left_top_back=[-1.,0.]
# iob.value_right_top_back=[0.,0.]

m = DruckerPrager(debug=dbg)
m.domain = Link(dom, "domain")

cv = VectorConstrainerOverBox(debug=dbg)
cv.domain = Link(dom, "domain")
cv.value = Link(iob, "out")

cv.left = [True, False, False]
cv.right = [True, True, True]
cv.bottom = [False, False, False]
cv.top = [False, False, False]
cv.front = [False, False, False]
cv.back = [False, False, False]

m.velocity = Link(iob, "out")
m.prescribed_velocity = Link(cv, "value_of_constraint")
m.location_prescribed_velocity = Link(cv, "location_of_constraint")
m.rel_tol = 0.01

m.expansion_coefficient = 0.
m.bulk_modulus = 1000.
m.shear_modulus = 1.
m.plastic_stress = 0.
m.friction_parameter = 0.
m.dilatancy_parameter = 0.
m.shear_length = m.shear_modulus * 0.9
コード例 #5
0
ファイル: run_convection.py プロジェクト: svn2github/Escript
def run(dom, stream):
    temp_val=InterpolateOverBox()
    temp_val.domain=Link(dom,"domain")
    temp_val.value_left_bottom_front=1.
    temp_val.value_right_bottom_front=1.
    temp_val.value_left_top_front=0.
    temp_val.value_right_top_front=0.
    temp_val.value_left_bottom_back=1.
    temp_val.value_right_bottom_back=1.
    temp_val.value_left_top_back=0.
    temp_val.value_right_top_back=0.

    temp_constraints=ScalarConstrainerOverBox()
    temp_constraints.domain=Link(dom)
    temp_constraints.top=1
    temp_constraints.bottom=1

    vel_constraints=VectorConstrainerOverBox()
    vel_constraints.domain=Link(dom)
    vel_constraints.left=[1,0,0]
    vel_constraints.right=[1,0,0]
    vel_constraints.top=[0,1,0]
    vel_constraints.bottom=[0,1,0]
    vel_constraints.front=[0,0,1]
    vel_constraints.back=[0,0,1]

    mat=SimpleEarthModel()
    mat.density0=1.
    mat.viscocity0=1.
    mat.rayleigh_number=10000.
    mat.alpha=0.001

    temp=TemperatureAdvection(debug=True)
    temp.domain=Link(dom)
    temp.density=Link(mat,"density0")
    temp.heat_capacity=Link(mat,"heat_capacity")
    temp.location_fixed_temperature=Link(temp_constraints,"location_of_constraint")
    temp.fixed_temperature=Link(temp_val,"out")
    temp.safety_factor=0.01
    mat.temperature=Link(temp,"temperature")
    grav=GravityForce()
    grav.domain=Link(dom,"domain")
    grav.direction=[0.,-1.,0.]
    grav.density=Link(mat,"density")
    grav.gravity=Link(mat,"gravity")


    vel=SteadyIncompressibleFlow(debug=True)
    vel.domain=Link(dom)
    vel.internal_force=Link(grav,"gravity_force")
    vel.viscosity=Link(mat,"viscosity")
    vel.location_prescribed_velocity=Link(vel_constraints,"location_of_constraint")
    vel.rel_tol=1.e-6
    temp.velocity=Link(vel,"velocity")

    sq=Sequencer()
    sq.t_end=0.001

    vis=WriteVTK()
    vis.t=Link(sq)
    vis.data0=Link(temp,"temperature")
    vis.data1=Link(vel,"velocity")
    vis.dt=0.0001
    vis.filename=os.path.join(WORKDIR,"temp.vtu")

    per=GaussianProfile()
    per.domain=Link(dom)
    per.x_c=[0.5,0.5,0.5]
    per.A=0.0001
    per.width=0.01
    per.r=0

    lc=LinearCombination()
    lc.f0=1.
    lc.v0=Link(per,"out")
    lc.f1=1.
    lc.v1=Link(temp_val,"out")
    temp.temperature=Link(lc,"out")

    s=Simulation([sq,vel_constraints, temp_constraints,Simulation([vel],debug=True),temp,vis],debug=True)
    s.writeXML(stream)
    s.run()
コード例 #6
0
ファイル: drucker_prager.py プロジェクト: svn2github/Escript
# iob.value_right_top_front=[0.,0.]
# iob.value_left_top_back=[-1.,0.]
# iob.value_right_top_back=[0.,0.]

m=DruckerPrager(debug=dbg)
m.domain=Link(dom,"domain")

cv=VectorConstrainerOverBox(debug=dbg)
cv.domain=Link(dom,"domain")
cv.value=Link(iob,"out")

cv.left=[True, False, False] 
cv.right= [True, True, True]
cv.bottom= [False, False, False]
cv.top= [False, False, False]
cv.front= [False, False, False]
cv.back= [False, False, False]

m.velocity=Link(iob,"out")
m.prescribed_velocity=Link(cv,"value_of_constraint")
m.location_prescribed_velocity=Link(cv,"location_of_constraint")
m.rel_tol=0.01

m.expansion_coefficient= 0.
m.bulk_modulus=1000.
m.shear_modulus=1.
m.plastic_stress=0.
m.friction_parameter=0.
m.dilatancy_parameter=0.
m.shear_length=m.shear_modulus*0.9