Ejemplo n.º 1
0
def create_bcs(Lx, Ly, Lx_inner,
               solutes,
               concentration_init,
               mesh,
               surface_charge,
               enable_NS, enable_EC,
               **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(
        right=[Right(Lx, Ly, Lx_inner)],
        left=[Left(Lx, Ly, Lx_inner)],
        #inner_wall=[InnerWall(Lx, Ly, Lx_inner)],
        #outer_wall=[OuterWall(Lx, Ly, Lx_inner)]
        wall=[Wall(Lx, Ly, Lx_inner)]
    )

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()

    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["left"]["p"] = Pressure(0.)
        bcs["right"]["p"] = Pressure(0.)
        #bcs["inner_wall"]["u"] = noslip
        #bcs["outer_wall"]["u"] = noslip
        bcs["wall"]["u"] = noslip

    if enable_EC:
        bcs["left"]["V"] = Fixed(0.)
        bcs["right"]["V"] = Charged(0.)
        #bcs["right"]["V"] = Fixed(0.)
        #bcs["outer_wall"]["V"] = Charged(0.)
        #bcs["inner_wall"]["V"] = Charged(surface_charge)
        bcs["wall"]["V"] = Charged(df.Expression(
            "0.5*sigma_e*(tanh((x[0]-0.5*(Lx-Lx_inner))/delta)-"
            "tanh((x[0]-0.5*(Lx+Lx_inner))/delta))",
            sigma_e=surface_charge, delta=2., Lx=Lx, Lx_inner=Lx_inner,
            degree=1))
        for solute in solutes:
            bcs["left"][solute[0]] = Fixed(concentration_init)
            bcs["right"][solute[0]] = Fixed(concentration_init)

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 2
0
def create_bcs(Lx, Ly, mesh, surface_charge, enable_NS, enable_EC,
               **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(right=[Right(Lx)],
                      left=[Left(Lx)],
                      bottom=[Bottom(Ly)],
                      top=[Top(Ly)])

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()

    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["left"]["u"] = noslip
        bcs["right"]["u"] = noslip
        bcs["top"]["u"] = noslip
        bcs["bottom"]["u"] = noslip
        bcs_pointwise["p"] = (0., "x[0] < DOLFIN_EPS-{Lx}/2 && "
                              "x[1] < DOLFIN_EPS-{Ly}/2".format(Lx=Lx, Ly=Ly))

    if enable_EC:
        bcs["top"]["V"] = Fixed(0.)
        bcs["bottom"]["V"] = Charged(surface_charge)

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 3
0
def create_bcs(Lx, Ly, velocity_top, solutes, concentration_init,
               surface_charge, surface_potential, enable_NS, enable_PF,
               enable_EC, **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(top=[Top(Ly)], bottom=[Bottom()])

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()

    u_top = Fixed((velocity_top, 0.))
    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["top"]["u"] = u_top
        bcs["bottom"]["u"] = noslip
        bcs_pointwise["p"] = (
            0., "x[0] < DOLFIN_EPS && x[1] > {Ly}-DOLFIN_EPS".format(Ly=Ly))

    if enable_EC:
        for solute in solutes:
            bcs["top"][solute[0]] = Fixed(concentration_init / abs(solute[1]))
        bcs["top"]["V"] = Fixed(0.)
        if surface_potential:
            bcs["bottom"]["V"] = Fixed(surface_charge)
        else:
            bcs["bottom"]["V"] = Charged(surface_charge)

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 4
0
def create_bcs(Lx, Ly, solutes, surface_charge, enable_NS, enable_PF,
               enable_EC, **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(right=[Right(Lx)],
                      left=[Left(0)],
                      bottom=[Bottom(0)],
                      top=[Top(Ly)])
    c0 = [1.0, 1.0]
    noslip = Fixed((0., 0.))
    V_ground = Fixed(0.0)
    surfacecharge = Charged(surface_charge)

    bcs = dict()
    bcs_pointwise = dict()
    bcs["right"] = dict()
    bcs["left"] = dict()
    bcs["top"] = dict()
    bcs["bottom"] = dict()

    if enable_NS:
        bcs["right"]["u"] = noslip
        bcs["left"]["u"] = noslip
        bcs["top"]["u"] = noslip
        bcs_pointwise["p"] = (0., "x[0] < DOLFIN_EPS && x[1] < DOLFIN_EPS")

    if enable_EC:
        bcs["top"]["V"] = surfacecharge
        bcs["bottom"]["V"] = V_ground
        for ci, solute in zip(c0, solutes):
            bcs["bottom"][solute[0]] = Fixed(ci)

    # Apply pointwise BCs e.g. to pin pressure.

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 5
0
def create_bcs(
        Lx,
        Ly,
        grid_spacing,  # inlet_velocity,
        concentration_init,
        solutes,
        surface_charge,
        V_left,
        V_right,
        pressure_left,
        pressure_right,
        enable_NS,
        enable_PF,
        enable_EC,
        **namespace):
    """ The boundaries and boundary conditions are defined here. """

    data = np.loadtxt("meshes/periodic_porous_dx" + str(grid_spacing) + ".dat")
    centroids = data[:, :2]
    rad = data[:, 2]

    boundaries = dict(right=[Right(Lx)],
                      left=[Left(Lx)],
                      obstacles=[Obstacles(Lx, centroids, rad, grid_spacing)])

    # Allocating the boundary dicts
    bcs = dict()
    bcs_pointwise = dict()
    for boundary in boundaries:
        bcs[boundary] = dict()

    # u_inlet = Fixed((inlet_velocity, 0.))
    noslip = Fixed((0., 0.))

    p_inlet = Pressure(pressure_left)
    p_outlet = Pressure(pressure_right)
    phi_inlet = Fixed(-1.0)
    phi_outlet = Fixed(1.0)

    if enable_NS:
        # bcs["left"]["u"] = u_inlet
        bcs["obstacles"]["u"] = noslip
        bcs["right"]["p"] = p_outlet
        bcs["left"]["p"] = p_inlet
        # bcs_pointwise["p"] = (0., "x[0] < -{Lx}/2+DOLFIN_EPS && x[1] > {Ly}/2-DOLFIN_EPS".format(Lx=Lx, Ly=Ly))

    if enable_PF:
        bcs["left"]["phi"] = phi_inlet
        bcs["right"]["phi"] = phi_outlet

    if enable_EC:
        for solute in solutes:
            bcs["left"][solute[0]] = Fixed(concentration_init)
            # bcs["right"][solute[0]] = Fixed(0.)
        bcs["left"]["V"] = Fixed(V_left)
        bcs["right"]["V"] = Fixed(V_right)
        bcs["obstacles"]["V"] = Charged(surface_charge)

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 6
0
def create_bcs(Lx, Ly, R, velocity_top, solutes, concentration_init,
               surface_charge, V_left, V_right, pressure_left, pressure_right,
               enable_NS, enable_PF, enable_EC, **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(outer_narrowing=[OuterNarrowing(Lx, R)],
                      inner_narrowing=[InnerNarrowing(Lx, R)],
                      right=[Right(Lx)],
                      left=[Left(0)])

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()
    ground = Fixed(0.)
    noslip = Fixed((0., 0.))
    phi_inlet = Fixed(-1.0)
    phi_outlet = Fixed(1.0)
    p_inlet = Pressure(pressure_left)
    p_outlet = Pressure(pressure_right)
    if enable_NS:
        bcs["inner_narrowing"]["u"] = noslip
        bcs["outer_narrowing"]["u"] = noslip
        bcs["left"]["p"] = p_inlet
        bcs["right"]["p"] = p_outlet
        #bcs_pointwise["p"] = (0., "x[0] < DOLFIN_EPS && x[1] > {Ly}-DOLFIN_EPS".format(Ly=Ly))

    if enable_EC:
        for solute in solutes:
            bcs["left"][solute[0]] = Fixed(concentration_init)
            bcs["right"][solute[0]] = Fixed(concentration_init)

        bcs["left"]["V"] = Fixed(V_left)
        bcs["right"]["V"] = Fixed(V_right)
        bcs["outer_narrowing"]["V"] = Charged(0.0)
        bcs["inner_narrowing"]["V"] = Charged(surface_charge)
        #bcs_pointwise["V"] = (0., "x[0] < DOLFIN_EPS && x[1] > {Ly}-DOLFIN_EPS".format(Ly=Ly))

        #if enable_PF:
        bcs["left"]["phi"] = phi_inlet
        bcs["right"]["phi"] = phi_inlet

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 7
0
def create_bcs(Lx, Ly,
               grid_spacing, rad, num_obstacles,
               surface_charge, solutes, enable_NS, enable_EC,
               p_lagrange, V_lagrange,
               concentration_init, V_left,
               **namespace):
    """ The boundaries and boundary conditions are defined here. """
    data = np.loadtxt(
        "meshes/periodic_porous_Lx{}_Ly{}_rad{}_N{}_dx{}.dat".format(
            Lx, Ly, rad, num_obstacles, grid_spacing))
    centroids = data[:, :2]
    rad = data[:, 2]

    boundaries = dict(
        left=[Left(Lx, Ly)],
        right=[Right(Lx, Ly)],
        obstacles=[Obstacles(Lx, centroids, rad, grid_spacing)]
    )

    # Allocating the boundary dicts
    bcs = dict()
    bcs_pointwise = dict()
    for boundary in boundaries:
        bcs[boundary] = dict()

    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["left"]["p"] = Pressure(0.)
        bcs["right"]["p"] = Pressure(0.)
        bcs["obstacles"]["u"] = noslip

    if enable_EC:
        for solute in solutes:
            bcs["left"][solute[0]] = Fixed(concentration_init)
            bcs["right"][solute[0]] = Fixed(concentration_init)
        bcs["left"]["V"] = Fixed(V_left)
        bcs["right"]["V"] = Charged(0.)
        # bcs["right"]["V"] = Fixed(V_right)
        bcs["obstacles"]["V"] = Charged(surface_charge)

    return boundaries, bcs, bcs_pointwise
def create_bcs(Lx, Ly, mesh, grid_spacing, rad, num_obstacles, surface_charge,
               solutes, enable_NS, enable_EC, p_lagrange, V_lagrange,
               **namespace):
    """ The boundaries and boundary conditions are defined here. """
    data = np.loadtxt(
        "meshes/periodic_porous_Lx{}_Ly{}_rad{}_N{}_dx{}.dat".format(
            Lx, Ly, rad, num_obstacles, grid_spacing))
    centroids = data[:, :2]
    rad = data[:, 2]

    # Find a single node to pin pressure to
    x_loc = np.array(mesh.coordinates())
    x_proc = np.zeros((size, 2))
    ids_notboun = np.logical_and(
        x_loc[:, 0] > x_loc[:, 0].min() + df.DOLFIN_EPS,
        x_loc[:, 1] > x_loc[:, 1].min() + df.DOLFIN_EPS)
    x_loc = x_loc[ids_notboun, :]
    d2 = (x_loc[:, 0] + Lx / 2)**2 + (x_loc[:, 1] + Ly / 2)**2
    x_bottomleft = x_loc[d2 == d2.min()][0]
    x_proc[rank, :] = x_bottomleft
    x_pin = np.zeros_like(x_proc)
    comm.Allreduce(x_proc, x_pin, op=MPI.SUM)
    x_pin = x_pin[x_pin[:, 0] == x_pin[:, 0].min(), :][0]

    info("Pinning point: {}".format(x_pin))

    pin_code = ("x[0] < {x}+{eps} && "
                "x[0] > {x}-{eps} && "
                "x[1] > {y}-{eps} && "
                "x[1] < {y}+{eps}").format(x=x_pin[0], y=x_pin[1], eps=1e-3)

    boundaries = dict(obstacles=[Obstacles(Lx, centroids, rad, grid_spacing)])

    # Allocating the boundary dicts
    bcs = dict()
    bcs_pointwise = dict()
    for boundary in boundaries:
        bcs[boundary] = dict()

    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["obstacles"]["u"] = noslip

        if not p_lagrange:
            bcs_pointwise["p"] = (0., pin_code)

    if enable_EC:
        bcs["obstacles"]["V"] = Charged(surface_charge)

        if not V_lagrange:
            bcs_pointwise["V"] = (0., pin_code)

    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 9
0
def create_bcs(Lx, Ly, surface_charge_top, surface_charge_bottom, enable_NS,
               enable_PF, enable_EC, **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(top=[Top(Ly)], bottom=[Bottom()])

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()

    noslip = Fixed((0., 0.))

    if enable_NS:
        bcs["top"]["u"] = noslip
        bcs["bottom"]["u"] = noslip
        bcs_pointwise["p"] = (0., "x[0] < DOLFIN_EPS && x[1] < DOLFIN_EPS")

    if enable_EC:
        bcs["top"]["V"] = Charged(surface_charge_top)
        bcs["bottom"]["V"] = Charged(surface_charge_bottom)
        bcs_pointwise["V"] = (0., "x[0] < DOLFIN_EPS && x[1] < DOLFIN_EPS")
    return boundaries, bcs, bcs_pointwise
Ejemplo n.º 10
0
def create_bcs(Lx, Ly, solutes, concentration_init, surface_charge,
               pressure_left, pressure_right, enable_NS, enable_PF, enable_EC,
               **namespace):
    """ The boundaries and boundary conditions are defined here. """
    boundaries = dict(
        inner=[Inner(Lx, Ly)],
        bottom=[Bottom()],
        top=[Top(Ly)],
        left=[Left()],
        right=[Right(Lx)],
    )

    bcs = dict()
    for boundary_name in boundaries.keys():
        bcs[boundary_name] = dict()

    # Apply pointwise BCs e.g. to pin pressure.
    bcs_pointwise = dict()

    noslip = Fixed((0., 0.))
    phi_inlet = Fixed(-1.0)
    p_inlet = Pressure(pressure_left)
    p_outlet = Pressure(pressure_right)

    if enable_NS:
        bcs["top"]["u"] = noslip
        bcs["bottom"]["u"] = noslip
        bcs["inner"]["u"] = noslip
        bcs["left"]["p"] = p_inlet
        bcs["right"]["p"] = p_outlet
        #bcs_pointwise["p"] = (0., "x[0] < DOLFIN_EPS && x[1] < DOLFIN_EPS")
        # bcs["outer"]["p"] = Pressure(0.)

    if enable_EC:
        for solute in solutes:
            bcs["left"][solute[0]] = Fixed(concentration_init)
            bcs["right"][solute[0]] = Fixed(concentration_init)
        bcs["top"]["V"] = Fixed(0.)
        bcs["bottom"]["V"] = Fixed(0.)
        bcs["left"]["V"] = Fixed(0.)
        bcs["right"]["V"] = Fixed(0.)
        bcs["inner"]["V"] = Charged(surface_charge)

    if enable_PF:
        bcs["left"]["phi"] = phi_inlet
        #bcs["right"]["phi"] = phi_inlet

    return boundaries, bcs, bcs_pointwise