def uOfXT(self,x,t):
     if shockSignedDistance(x) < 0:
         return -g[2]*(rho_0*(height - x[2])
                       -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,height-waterColumn_z)
                       +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,x[2]-waterColumn_z))
     else:
         return -rho_1*g[2]
Пример #2
0
 def uOfXT(self,x,t):
     if shockSignedDistance(x) < 0:
         return -g[2]*(rho_0*(height - x[2])
                       -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*0.1,height-waterColumn_z)
                       +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*0.1,x[2]-waterColumn_z))
     else:
         return -rho_1*g[2]
Пример #3
0
def twpflowPressure_init(x, t):
    p_L = 0.0
    phi_L = tank_dim[nd - 1] - waterLevel
    phi = x[nd - 1] - waterLevel
    return p_L - g[nd - 1] * (rho_0 * (phi_L - phi) + (rho_1 - rho_0) * (
        smoothedHeaviside_integral(epsFact_consrv_heaviside * opts.he, phi_L) -
        smoothedHeaviside_integral(epsFact_consrv_heaviside * opts.he, phi)))
Пример #4
0
 def p_dirichlet(x,t):
   p_L = default_p.L[axis]*rho_air*gravity[axis]
   phi_L = default_p.L[axis] - waterLevel
   phi = x[axis] - waterLevel
   return p_L - gravity[axis]*(  rho_water*(phi_L - phi)
                               + (rho_air -rho_water)*(smoothedHeaviside_integral(epsFact*he,phi_L)
                                                      -smoothedHeaviside_integral(epsFact*he,phi)))
Пример #5
0
def outflowPressure(x,t):
    #return min(L[2] - x[2],L[2]-waterLevel)*rho_1*(-g[2]) + max(waterLevel - x[2],0.0)*rho_0*(-g[2])
    p_L = L[2]*rho_1*g[2]
    phi_L = L[2] - outflowHeight
    phi = x[2] - outflowHeight
    return p_L -g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                         -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #6
0
def twpflowPressure(x,t):
    #return min(L[2] - x[2],L[2]-waterLevel)*rho_1*(-g[2]) + max(waterLevel - x[2],0.0)*rho_0*(-g[2])
    p_L = L[2]*rho_1*g[2]
    phi_L = wavePhi((x[0],x[1],L[2]),t) 
    phi = wavePhi(x,t)
    return p_L - g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                          -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
 def p(x, t):
     return -coefficients.g[2] * (
         rho_0 * (height - x[2]) -
         (rho_0 - rho_1) * smoothedHeaviside_integral(
             epsFact_density * he, height - waterLevel) +
         (rho_0 - rho_1) * smoothedHeaviside_integral(
             epsFact_density * he, x[2] - waterLevel))
Пример #8
0
def twpflowPressure_init(x, t):
    p_L = L[2] * rho_1 * g[2]
    phi_L = L[2] - inflowHeightMean
    phi = x[2] - inflowHeightMean
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
Пример #9
0
def outflowPressure(x, t):
    p_L = L[2] * rho_1 * g[2]
    phi_L = L[2] - outflowHeight
    phi = x[2] - outflowHeight
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
Пример #10
0
 def uOfXT(self, x, t):
     p_top = 0.0
     phi_top = xTop
     phi = x[vert_axis] - opts.outlet_level
     return p_top - opts.g[vert_axis] * (
         opts.rho_0 * (phi_top - phi) + (opts.rho_1 - opts.rho_0) *
         (smoothedHeaviside_integral(smoothing, phi_top) -
          smoothedHeaviside_integral(smoothing, phi)))
Пример #11
0
 def uOfXT(self, x, t):
     p_L = 0.0
     phi_L = tank.dim[nd - 1] - water_level
     phi = x[nd - 1] - water_level
     p = p_L - g[nd - 1] * (rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
                            (smoothedHeaviside_integral(smoothing, phi_L) -
                             smoothedHeaviside_integral(smoothing, phi)))
     return p
Пример #12
0
def twpflowPressure(x, t):
    p_L = L[2] * rho_1 * g[2]
    phi_L = wavePhi((x[0], x[1], L[2]), t)
    phi = wavePhi(x, t)
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
Пример #13
0
def outflowPressure(x, t):
    p_L = L[1] * rho_1 * g[1]
    phi_L = L[1] - outflowHeight
    phi = x[1] - outflowHeight
    return p_L - g[1] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_density * he, phi_L) -
         smoothedHeaviside_integral(epsFact_density * he, phi)))
Пример #14
0
def smoothedHydrostaticPressure(waterLevel, z):
    p_L = L[2] * rho_1 * g[2]
    phi = z - waterLevel
    phi_L = L[2] - waterLevel
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
Пример #15
0
def twpflowPressure_init(x, t):
    p_L = 0.0
    phi_L = tank_dim[nd - 1] - waterLevel
    phi = x[nd - 1] - waterLevel
    return p_L - g[nd - 1] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(ecH * domain.MeshOptions.he, phi_L) -
         smoothedHeaviside_integral(ecH * domain.MeshOptions.he, phi)))
Пример #16
0
def intwpflowPressure(X, t):
    p_top = 0.0
    phi_top = topy - waterLevel
    phi = X[1] - waterLevel
    return p_top - g[1]*(rho_0*(phi_top - phi) + \
                         (rho_1 -rho_0) * \
                         (smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_top)
                          -
                          smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #17
0
def outtwpflowPressure(X, t):
    p_top = 0.0
    phi_top = topy - tailwater
    phi = X[1] - tailwater
    return p_top - g[1]*(rho_0*(phi_top - phi) +
                         (rho_1 -rho_0) * \
                         (smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_top)
                          -
                          smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #18
0
 def hydrostaticPressureOutletWithDepth_p_dirichlet(x, t):
     p_top = pRef
     phi_top = refLevel - seaLevel
     phi = x[vert_axis] - seaLevel
     return p_top - g[vert_axis]*(rhoDown*(phi_top - phi) + \
                  (rhoUp -rhoDown) * \
                  (smoothedHeaviside_integral(smoothing,phi_top)
                   -
                   smoothedHeaviside_integral(smoothing,phi)))
Пример #19
0
def twpflowPressure(x, t):
    #return min(L[2] - x[2],L[2]-waterLevel)*rho_1*(-g[2]) + max(waterLevel - x[2],0.0)*rho_0*(-g[2])
    p_L = L[2] * rho_1 * g[2]
    phi_L = wavePhi((x[0], x[1], L[2]), t)
    phi = wavePhi(x, t)
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
Пример #20
0
def outflowPressure(x, t):
    #return min(L[2] - x[2],L[2]-waterLevel)*rho_1*(-g[2]) + max(waterLevel - x[2],0.0)*rho_0*(-g[2])
    p_L = L[2] * rho_1 * g[2]
    phi_L = L[2] - outflowHeight
    phi = x[2] - outflowHeight
    return p_L - g[2] * (
        rho_0 * (phi_L - phi) + (rho_1 - rho_0) *
        (smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi_L) -
         smoothedHeaviside_integral(epsFact_consrv_heaviside * he, phi)))
def getDBC_p(x,flag):
    if altBC:
        if flag in [boundaryTags['downstream'],boundaryTags['top']]:
            return lambda x,t: -coefficients.g[2]*(rho_0*(inflow_height - x[2])
                                                   -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,inflow_height-waterLevel)
                                                   +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,x[2]-waterLevel))
    else:
        if flag == boundaryTags['downstream']:
            return lambda x,t: -coefficients.g[2]*(rho_0*(inflow_height - x[2])
                                                   -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,inflow_height-waterLevel)
                                                   +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,x[2]-waterLevel))
Пример #22
0
def outflowPressure(x, t):
    p_L = L[1] * rho_1 * g[1]
    phi_L = L[1] - outflowHeight
    phi = x[1] - outflowHeight
    return p_L - g[1] * (
        rho_0 * (phi_L - phi)
        + (rho_1 - rho_0)
        * (
            smoothedHeaviside_integral(epsFact_density * he, phi_L)
            - smoothedHeaviside_integral(epsFact_density * he, phi)
        )
    )
Пример #23
0
def twpflowPressure_init(x, t):
    p_L = 0.0
    phi_L = tank_dim[nd-1] - water_level
    phi = x[nd-1] - water_level
    return p_L -g[nd-1]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                         -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #24
0
    def uOfXT(self, x, t):
        return 0.0
class PHI_IC:
    def uOfXT(self, x, t):
        return x[vert_axis]-opts.outlet_level
class VF_IC:
    def uOfXT(self, x, t):
        return smoothedHeaviside(smoothing,opts.outlet_level-x[vert_axis]) 
class P_IC:
    def uOfXT(self, x, t):        
        p_top = 0.0
        phi_top = xTop
        phi = x[vert_axis] - opts.outlet_level
        return p_top - opts.g[vert_axis] * (opts.rho_0 * (phi_top - phi) +
                                       (opts.rho_1 - opts.rho_0) *
                                       (smoothedHeaviside_integral(smoothing, phi_top)-
                                        smoothedHeaviside_integral(smoothing, phi)))

initialConditions = {'pressure': P_IC(),
                     'vel_u': At_Rest(),
                     'vel_v': At_Rest(),
                     'vel_w':At_Rest(),
                     'vof': VF_IC(),
                     'ncls': PHI_IC(),
                     'rdls': PHI_IC()}
outputStepping = TpFlow.OutputStepping(final_time=opts.T,
                                       dt_init=opts.dt_init,
                                       dt_output=opts.dt_output,
                                       nDTout=None,
                                       dt_fixed=None)
Пример #25
0
 def p(x,t):
     return -coefficients.g[2]*(rho_0*(height - x[2])
                                -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,height-waterLevel)
                                +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,x[2]-waterLevel))
Пример #26
0
def twpflowPressure_init(x,t):
    p_L = L[2]*rho_1*g[2]
    phi_L = L[2] - inflowHeightMean
    phi = x[2] - inflowHeightMean
    return p_L -g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                          -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #27
0
 def test_hydrostatic_pressure_outlet_with_depth(self):
     from proteus.ctransportCoefficients import smoothedHeaviside, smoothedHeaviside_integral
     # input 
     ct = get_context()
     b_or = np.array([[0., -1., 0.]])
     b_i = 0
     seaLevel = 0.5 # m
     rhoUp = 1.004e-6 # kg/m3
     rhoDown = 1.500e-5 # kg/m3
     g = np.array([0., -9.81, 0.]) # m/s2
     refLevel = seaLevel
     smoothing = 3.*0.01 # m
     nd = 2
     vert_axis = nd - 1
     air = 1.
     water = 0.
     pRef = 0. # Pa
     BC = create_BC(folder='mprans', b_or=b_or, b_i=b_i)
     # setting variables
     uDir, vDir, wDir, vofDir, pDir, uDiff, kDiff, dissDiff = [],[],[],[],[],[],[],[]
     vofCalc, pCalc = [],[]
     t_list = get_time_array()
     BC.setHydrostaticPressureOutletWithDepth(seaLevel, rhoUp, rhoDown, g, refLevel, smoothing)
     # time step iterations
     for t in t_list:
         x = np.array(get_random_x())
         vofDir += [BC.vof_dirichlet.uOfXT(x, t)]
         pDir += [BC.p_dirichlet.uOfXT(x, t)]
         # Relative system of coordinates based on the point chosen as reference with pressure=pRef
         phiCalc = x[vert_axis] - seaLevel
         phi_top = refLevel - seaLevel
         phi_ref = phi_top - phiCalc
         rho_diff = rhoUp - rhoDown
         phi_diff = smoothedHeaviside_integral(smoothing, phi_top) - smoothedHeaviside_integral(smoothing, phiCalc)
         pTot = pRef - (g[vert_axis]*rhoDown*phi_ref) - (g[vert_axis]*rho_diff*phi_diff)
         pCalc += [pTot]
         # smoothing for vof activated along either the water-phase and air phase side
         if phiCalc <= -smoothing: 
             Heav = 0.
         elif -smoothing < phiCalc < smoothing: 
             Heav = smoothedHeaviside(smoothing, phiCalc)
         else: 
             Heav = 1.
         vofCalc += [Heav*air + (1.-Heav)*water]
         # Velocity and turbulence variables
         uDir += [BC.u_dirichlet.uOfXT(x, t)]
         vDir += [BC.v_dirichlet.uOfXT(x, t)]
         wDir += [BC.w_dirichlet.uOfXT(x, t)]
         uDiff += [BC.u_diffusive.uOfXT(x, t)]
         kDiff += [BC.k_diffusive.uOfXT(x, t)]
         dissDiff += [BC.dissipation_diffusive.uOfXT(x, t)]
     nt = len(t_list)
     uCalc, vCalc, wCalc, uDiffCalc, kCalc, dissCalc = np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt)
     npt.assert_equal(uDir, uCalc)
     npt.assert_equal(vDir, vCalc)
     npt.assert_equal(wDir, wCalc)
     npt.assert_allclose(pDir, pCalc, atol=1e-10)
     npt.assert_equal(vofDir, vofCalc)
     npt.assert_equal(uDiff, uDiffCalc)
     npt.assert_equal(kDiff, kCalc)
     npt.assert_equal(dissDiff, dissCalc)
Пример #28
0
def outflowPressure(x,t):
    p_L = L[2]*rho_1*g[2]
    phi_L = L[2] - outflowHeight
    phi = x[2] - outflowHeight
    return p_L -g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                          -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #29
0
def twpflowPressure(x,t):
    p_L = L[2]*rho_1*g[2]
    phi_L = wavePhi((x[0],x[1],L[2]),t) 
    phi = wavePhi(x,t)
    return p_L -g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                          -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
Пример #30
0
 def test_hydrostatic_pressure_outlet_with_depth(self):
     from proteus.ctransportCoefficients import smoothedHeaviside, smoothedHeaviside_integral
     # input 
     ct = get_context()
     b_or = np.array([[0., -1., 0.]])
     b_i = 0
     seaLevel = 0.5 # m
     rhoUp = 1.004e-6 # kg/m3
     rhoDown = 1.500e-5 # kg/m3
     g = np.array([0., -9.81, 0.]) # m/s2
     refLevel = seaLevel
     smoothing = 3.*0.01 # m
     nd = 2
     vert_axis = nd - 1
     air = 1.
     water = 0.
     pRef = 0. # Pa
     BC = create_BC(folder='mprans', b_or=b_or, b_i=b_i)
     # setting variables
     uDir, vDir, wDir, vofDir, pDir, uDiff, kDiff, dissDiff = [],[],[],[],[],[],[],[]
     vofCalc, pCalc = [],[]
     t_list = get_time_array()
     BC.setHydrostaticPressureOutletWithDepth(seaLevel, rhoUp, rhoDown, g, refLevel, smoothing)
     # time step iterations
     for t in t_list:
         x = np.array(get_random_x())
         vofDir += [BC.vof_dirichlet.uOfXT(x, t)]
         pDir += [BC.p_dirichlet.uOfXT(x, t)]
         # Relative system of coordinates based on the point chosen as reference with pressure=pRef
         phiCalc = x[vert_axis] - seaLevel
         phi_top = refLevel - seaLevel
         phi_ref = phi_top - phiCalc
         rho_diff = rhoUp - rhoDown
         phi_diff = smoothedHeaviside_integral(smoothing, phi_top) - smoothedHeaviside_integral(smoothing, phiCalc)
         pTot = pRef - (g[vert_axis]*rhoDown*phi_ref) - (g[vert_axis]*rho_diff*phi_diff)
         pCalc += [pTot]
         # smoothing for vof activated along either the water-phase and air phase side
         if phiCalc <= -smoothing: 
             Heav = 0.
         elif -smoothing < phiCalc < smoothing: 
             Heav = smoothedHeaviside(smoothing, phiCalc)
         else: 
             Heav = 1.
         vofCalc += [Heav*air + (1.-Heav)*water]
         # Velocity and turbulence variables
         uDir += [BC.u_dirichlet.uOfXT(x, t)]
         vDir += [BC.v_dirichlet.uOfXT(x, t)]
         wDir += [BC.w_dirichlet.uOfXT(x, t)]
         uDiff += [BC.u_diffusive.uOfXT(x, t)]
         kDiff += [BC.k_diffusive.uOfXT(x, t)]
         dissDiff += [BC.dissipation_diffusive.uOfXT(x, t)]
     nt = len(t_list)
     uCalc, vCalc, wCalc, uDiffCalc, kCalc, dissCalc = np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt), np.zeros(nt)
     npt.assert_equal(uDir, uCalc)
     npt.assert_equal(vDir, vCalc)
     npt.assert_equal(wDir, wCalc)
     npt.assert_allclose(pDir, pCalc, atol=1e-10)
     npt.assert_equal(vofDir, vofCalc)
     npt.assert_equal(uDiff, uDiffCalc)
     npt.assert_equal(kDiff, kCalc)
     npt.assert_equal(dissDiff, dissCalc)
Пример #31
0
def smoothedHydrostaticPressure(waterLevel,z):
    p_L = L[2]*rho_1*g[2]
    phi = z - waterLevel 
    phi_L = L[2] - waterLevel 
    return p_L -g[2]*(rho_0*(phi_L - phi)+(rho_1 -rho_0)*(smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi_L)
                                                          -smoothedHeaviside_integral(epsFact_consrv_heaviside*he,phi)))
 def uOfXT(self,x,t):
     return -coefficients.g[2]*(rho_0*(inflow_height - x[2])
                                -(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,inflow_height-waterLevel)
                                +(rho_0-rho_1)*smoothedHeaviside_integral(epsFact_density*he,x[2]-waterLevel))