Exemplo n.º 1
0
def geo_from_xml_threadsafe(name, reuse_mesh=False, clscale=None, **params):
    import os, mpi4py
    comm = mpi_comm_self()

    if mpi4py.MPI.COMM_WORLD.Get_size() > 1:
        pid = str(mpi4py.MPI.COMM_WORLD.Get_rank())
    else:
        pid = str(os.getpid())

    if not reuse_mesh:
        nanopores.generate_mesh(clscale, name, pid=pid, **params)

    DIR = "%s/%s/mesh/" % (nanopores.DATADIR, name)
    mesh = Mesh(comm, DIR + "mesh%s.xml" % pid)
    subdomains = MeshFunction("size_t", mesh,
                              DIR + "mesh%s_physical_region.xml" % pid)
    boundaries = MeshFunction("size_t", mesh,
                              DIR + "mesh%s_facet_region.xml" % pid)

    with open(DIR + "meta%s.txt" % pid, "r") as f:
        meta = eval(f.read())

    physdom = meta.pop("physical_domain")
    physbou = meta.pop("physical_boundary")

    module = "nanopores.geometries.%s.params_geo" % name
    params = nanopores.import_vars(module)
    params.update(meta)
    params["name"] = name
    syn = params.pop("synonymes")

    return Geometry(None, mesh, subdomains, boundaries, physdom, physbou, syn,
                    params)
Exemplo n.º 2
0
def geo_from_xml(name):
    DIR = "%s/%s/mesh/" %(nanopores.DATADIR, name)
    mesh = Mesh(DIR+"mesh.xml")
    subdomains = MeshFunction("size_t", mesh, filename=DIR+"mesh_physical_region.xml")
    boundaries = MeshFunction("size_t", mesh, filename=DIR+"mesh_facet_region.xml")

    with open(DIR+"meta.txt", "r") as f:
        meta = eval(f.read())

    physdom = meta.pop("physical_domain")
    physbou = meta.pop("physical_boundary")

    module = "nanopores.geometries.%s.params_geo" %name
    params = nanopores.import_vars(module)
    params.update(meta)
    params["name"] = name
    syn = params.pop("synonymes")

    return Geometry(None, mesh, subdomains, boundaries, physdom, physbou, syn, params)
Exemplo n.º 3
0
from nanopores import generate_mesh, geo_from_name, Poisson, PoissonProblem, qq, PB, PBProblem, import_vars, params_physical, get_mesh, u_to_matlab, IllposedNonlinearSolver
from dolfin import *
from random import random

t = Timer("time")
geo_name = "Nanowire"
globals().update(import_vars("nanopores.%s.params_geo" % geo_name))

def random_dopant_positions(N, **params):
    # create N random points in unit cube
    x = [[random() for i in range(3)] for i in range(N)]
    # affine transformation on transducer
    rr = params["r_eff"]
    ll = params["l"]
    T = lambda x : [x[0]*(w_core - 2*rr) + x_core + rr, x[1]*(ll - 2*rr) + rr,
                    x[2]*(h_core - 2*rr) + z_core + rr]
    return map(T, x)

N = 5 # number of impurity atoms in pore
l = 10 # length of wire [nm]
clscale = 1.0 # mesh width scale
Nsamples = 1 # number of samples
r_eff = 3 # effective radius [nm]
voltage = -3 # voltage drop across 1000 nm wire [V]

# change physical parameters
#params_physical.permanent_charge["impurity"] = 1e6
#params_physical.permittivity["impurity"] = ???
#params_physical.ion_concentration["impurity"] = ???

geo_params = dict(l = l*1e-9, r_eff = r_eff*1e-9, lc = 10e-9)
Exemplo n.º 4
0
# (c) 2017 Gregor Mitscha-Baude
from nanopores import geo_from_name, generate_mesh, user_params, import_vars

geo_name = "W_2D_geo"
geo_dict = import_vars("nanopores.geometries.%s.params_geo" % geo_name)
physical_dict = import_vars("nanopores.physics.params_physical")
default_dict = dict(geo_dict=geo_dict, physical_dict=physical_dict)

nm = geo_dict["nm"]
lsam = geo_dict["lsam"]
params = dict(
    x0=[0, 0, 0],
    outerfrac=0.2,
    lsam=lsam,
    r0=13 * nm - lsam,
    angle=40,
    sam=None,
)

generate_mesh(1., geo_name, **params)
geo = geo_from_name(geo_name, **params)

geo.plot_boundaries()
geo.plot_subdomains(interactive=True)