Exemplo n.º 1
0
def cache_pugh_diffusivity(geoname="pugh2", mode="coupled", **params):
    #name = "D%s-%s" % (geoname, mode)
    name = "D%s" % (geoname, )

    if not fields.exists(name, **params):
        if not "cheapest" in params:
            params["cheapest"] = True
        setup = pugh.Setup(x0=None, **params)
        r = setup.geop.rMolecule
        diamPore = setup.geop.diamPore

        if mode == "coupled":
            data_z = diff_profile_z_pugh(diamPore=diamPore)
            data_r = diff_profile_plane(r)
        elif mode == "simple":
            data_z = None
            data_r = diff_profile_plane(r)
        elif mode == "profile":
            data_z = diff_profile_z_pugh(diamPore=diamPore)
            data_r = diff_profile_trivial(r)
        else:
            raise NotImplementedError

        functions = diffusivity_field(setup,
                                      r,
                                      ddata_z=data_z,
                                      ddata_r=data_r,
                                      boundary="dnab",
                                      poreregion="poreregion")
        fields.save_functions(name, params, **functions)
        fields.update()

    return name
Exemplo n.º 2
0
def force_diff(**params):
    # for random walk (with pointsize force field, no current)
    setup = Setup(create_geo=False, **params)
    # DEBUG
    #print "active params", setup.active_params
    #print "inactive params", setup.inactive_params
    F = force_pointsize(**params)
    if setup.phys.posDTarget:
        D = diffusivity_simple(**params)
        name = "diffusivity_div_simple"
        if not fields.exists(name, **params):
            V = D.function_space()
            divD = dolfin.project(
                dolfin.as_vector([dolfin.grad(D[0])[0],
                                  dolfin.grad(D[1])[1]]), V)
            fields.save_functions(name, setup.active_params, divD=divD)
            fields.update()
        divD, = fields.get_functions(name, "divD", **params)
    else:
        D0 = setup.phys.DTargetBulk
        D0a = np.array([D0, D0, D0])
        divDa = np.array([0., 0., 0.])
        D = lambda x: D0a
        divD = lambda x: divDa
    return F, D, divD
Exemplo n.º 3
0
def cache_diffusivity(geoname="alphahem", mode="coupled", **params):
    name = "D%s-%s" % (geoname, mode)

    if not fields.exists(name, **params):
        setup = nanopore.Setup(**params)
        r = setup.geop.rMolecule

        if mode == "coupled":
            data_z = diff_profile_z_ahem(**params)
            data_r = diff_profile_plane(r)
        elif mode == "simple":
            data_z = None
            data_r = diff_profile_plane(r)
        elif mode == "profile":
            data_z = diff_profile_z_ahem(**params)
            data_r = diff_profile_trivial(r)
        else:
            raise NotImplementedError

        functions = diffusivity_field(setup,
                                      r,
                                      ddata_z=data_z,
                                      ddata_r=data_r,
                                      boundary="poresolidb",
                                      poreregion="pore")
        fields.save_functions(name, params, **functions)
        fields.update()

    return name
Exemplo n.º 4
0
def cache_diffusivity_simple(geoname="alphahem", **params):
    name = "D%s" % (geoname, )

    if not fields.exists(name, **params):
        setup = nanopore.Setup(**params)
        r = setup.geop.rMolecule
        functions = diffusivity_field(setup, r, boundary="poresolidb")
        fields.save_functions(name, params, **functions)
        fields.update()
Exemplo n.º 5
0
def distance_boundary():
    h = up.h
    geo = pughpore.get_geo(h)
    y = distance_boundary_from_geo(geo)
    print "Max distance:", y.vector().max()

    if not fields.exists("pugh_distance", h=h):
        fields.save_functions("pugh_distance", dict(h=h), y=y)
        fields.update()
    return y
Exemplo n.º 6
0
def diffusivity_simple(**params):
    from nanopores.models.diffusion_interpolation import diffusivity_field
    name = "diffusivity_simple"
    if not fields.exists(name, **params):
        setup = Setup(**params)
        dic = diffusivity_field(setup,
                                r=params["rMolecule"],
                                boundary="poresolidb")
        fields.save_functions(name, setup.active_params, **dic)
        fields.update()
    D, = fields.get_functions(name, "D", **params)
    return D
Exemplo n.º 7
0
def cache_pugh_diffusivity_alt(**params):
    "the function above applied to the pugh pore"
    if not fields.exists("Dpugh_alt", **params):
        setup_params = dict(params)
        r = setup_params.pop("r")
        ddata_pore = fields.get_fields("pugh_diff_pore", rMolecule=r)
        ddata_bulk = fields.get_fields("pugh_diff_bulk", rMolecule=r)
        if not "cheapest" in setup_params:
            setup_params["cheapest"] = True
        setup = pugh.Setup(x0=None, **setup_params)
        functions = diffusivity_field_alt(setup, r, ddata_pore, ddata_bulk)
        fields.save_functions("Dpugh_alt", params, **functions)
        fields.update()
Exemplo n.º 8
0
def cache_pugh_diffusivity_old(**params):
    "the function above applied to the pugh pore"
    if not fields.exists("Dpugh", **params):
        setup_params = dict(params)
        r = setup_params.pop("r")
        ddata_z = fields.get_fields("pugh_diff2D", rMolecule=r)
        ddata_r = fields.get_fields("pugh_diff3D", rMolecule=r, bulkbc=True)
        if not "cheapest" in setup_params:
            setup_params["cheapest"] = True
        setup = pugh.Setup(x0=None, **setup_params)
        functions = diffusivity_field(setup, r, ddata_r, ddata_z)
        fields.save_functions("Dpugh", params, **functions)
        fields.update()
Exemplo n.º 9
0
def force_pointsize(**params):
    name = "force_pointsize"
    if not fields.exists(name, **params):
        setup = Setup(**params)
        #print setup.geo
        #setup.geo.plot_boundaries(interactive=True)
        _, pnps = solve(setup, True)
        v, cp, cm, u, p = pnps.solutions()

        F, Fel, Fdrag = setup.phys.ForceField(v, u, "fluid")
        fields.save_functions(name,
                              setup.active_params,
                              F=F,
                              Fel=Fel,
                              Fdrag=Fdrag)
        fields.update()
    F, = fields.get_functions(name, "F", **params)
    return F
Exemplo n.º 10
0
def cache_diffusivity(mode="coupled", **params):
    #name = "D%s-%s" % (geoname, mode)
    name = "Diffusivity"

    if not fields.exists(name, **params):
        if not "cheapest" in params:
            params["cheapest"] = True
        # setup = pugh.Setup(x0=None, **params)
        setup = nanopore.Setup(x0=None, **params)
        r = params["r"]
        #diamPore = setup.geo.params.diamPore

        if mode == "coupled":
            # TODO: make general
            data_z = fields.get_fields("pugh_diff2D", rMolecule=r)
            data_r = diff_profile_plane(r)
        elif mode == "simple":
            data_z = None
            data_r = diff_profile_plane(r)
        elif mode == "profile":
            data_z = fields.get_fields("pugh_diff2D", rMolecule=r)
            #data_z = diff_profile_z_pugh(diamPore=diamPore)
            data_r = diff_profile_trivial(r)
        else:
            raise NotImplementedError

        functions = diffusivity_field(setup,
                                      r,
                                      ddata_z=data_z,
                                      ddata_r=data_r,
                                      boundary="dnab",
                                      poreregion="poreregion")
        params["mode"] = mode
        fields.save_functions(name, params, **functions)
        fields.update()

    return name
Exemplo n.º 11
0
# (c) 2016 Gregor Mitscha-Baude
from dolfin import *
from nanopores.tools import fields

# set save/load directory
fields.set_dir("/tmp/nanopores/")

mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
u.interpolate(Expression("sin(x[0]*x[1]*4*pi)"))

if not fields.exists("test_save"):
    fields.save_functions("test_save", {}, utest=u)
    fields.update()

functions, mesh = fields.get_functions("test_save")
u1 = functions["utest"]
plot(u1, interactive=True)
Exemplo n.º 12
0
def plot_polygon(p, lw=1):
    p.plot("-k", lw=lw)
    Polygon(minus(p.nodes)).plot("-k", lw=lw)


params = dict(
    h=0.5,
    Nmax=3e4,
    bV=0.0,
)
name = "pot-ahem"
if not fields.exists(name, **params):
    setup = model.Setup(**params)
    pb, pnps = model.solve(setup)
    v = pnps.solutions()[0]
    fields.save_functions(name, params, v=v)
    fields.update()

fun, mesh = fields.get_functions(name, **params)
f = fun["v"]


def F(x, z):
    if x >= 0:
        return f([x, z])
    else:
        return f([-x, z])


R, Htop, Hbot = 7, 2, 12
fig = plt.figure(figsize=(2.6, 2.15))
Exemplo n.º 13
0
    dim=2,
    x0=None,
    rMolecule=6.,
    Qmol=-1.,
    bV=-0.5,
)
fields.set_dir_dropbox()

name = "wei_force_ps"
if not fields.exists(name, **params):
    setup = nanopore.Setup(**params)
    _, pnps = nanopore.solve(setup, True)
    v, cp, cm, u, p = pnps.solutions()

    F, Fel, Fdrag = setup.phys.ForceField(v, u, "fluid")
    fields.save_functions(name, params, F=F, Fel=Fel, Fdrag=Fdrag)
    fields.update()

name_D = "wei_D_2D"
if not fields.exists(name_D, **params):
    setup = nanopore.Setup(**params)
    dic = diffusivity_field(setup,
                            r=params["rMolecule"],
                            boundary="poresolidb")
    fields.save_functions(name_D, params, **dic)
    fields.update()

F, Fel, Fdrag = fields.get_functions(name, "F", "Fel", "Fdrag", **params)
D, dist = fields.get_functions(name_D, "D", "dist", **params)

if __name__ == "__main__":