def diffusivity_tensor(setup): v0 = .001 geo, phys = setup.geo, setup.phys r = setup.geop.rMolecule dim = setup.phys.dim cyl = setup.phys.cyl if geo.mesh.num_cells() < setup.solverp.Nmax: pugh.prerefine(setup, True) iterative = False if dim == 3 and geo.mesh.num_cells() > 2e5: #pnps.SimpleStokesProblem.method["lusolver"] = "superlu" pnps.SimpleStokesProblem.method["kparams"]["maximum_iterations"] = 5000 iterative = True #False else: iterative = False U0 = dolfin.Constant(tuple(0. for i in range(dim))) W = pnps.SimpleStokesProblem.space(geo.mesh) bcs = [ geo.BC(W.sub(0), U0, "dnab"), geo.BC(W.sub(0), U0, "memb"), geo.BC(W.sub(0), U0, "sideb"), geo.BC(W.sub(1), dolfin.Constant(0.0), "upperb") ] if setup.physp.bulkbc: bcs.append(geo.BC(W.sub(0), U0, "bulk")) gamma = np.zeros((dim, dim)) for i0 in range(dim): U1 = dolfin.Constant(tuple( (v0 if i == i0 else 0.) for i in range(dim))) bcmol = [geo.BC(W.sub(0), U1, "moleculeb")] stokes = nano.solve_pde(pnps.SimpleStokesProblem, geo=geo, cyl=cyl, phys=phys, iterative=iterative, bcs=bcs + bcmol) F = stokes.evaluate(phys.Fdrag)["Fdrag"] gamma[:, i0] = abs(np.array(F) / v0) #dolfin.plot(stokes.solutions()[0]) #dolfin.plot(stokes.solutions()[1]) pi = phys.pi eta = phys.eta kT = phys.kT gamma0 = 6. * pi * eta * r * 1e-9 print "gamma (simulation):\n", gamma print "gamma (stokes law):", gamma0 print D = kT * np.linalg.inv(gamma) D0 = kT / gamma0 print "D (simulation):\n", D print "D (stokes law):", D0 print "Reducing factor due to confinement:\n", D / D0 return D / D0
def diffusivity(setup): v0 = .001 geo, phys = setup.geo, setup.phys r = setup.geop.rMolecule dim = setup.phys.dim cyl = setup.phys.cyl if geo.mesh.num_cells() < setup.solverp.Nmax: pugh.prerefine(setup, True) if dim == 3: pnps.SimpleStokesProblem.method["kparams"]["maximum_iterations"] = 5000 iterative = True else: iterative = False U0 = dolfin.Constant(tuple(0. for i in range(dim))) U1 = dolfin.Constant( tuple((v0 if i == dim - 1 else 0.) for i in range(dim))) W = pnps.SimpleStokesProblem.space(geo.mesh) bcs = [ geo.BC(W.sub(0), U0, "dnab"), geo.BC(W.sub(0), U0, "memb"), geo.BC(W.sub(0), U0, "sideb"), geo.BC(W.sub(0), U1, "moleculeb"), geo.BC(W.sub(1), dolfin.Constant(0.0), "upperb") ] if setup.physp.bulkbc: bcs.append(geo.BC(W.sub(0), U0, "bulk")) stokes = nano.solve_pde(pnps.SimpleStokesProblem, geo=geo, cyl=cyl, phys=phys, iterative=iterative, bcs=bcs) F = stokes.evaluate(phys.Fdrag)["Fdrag"] print F pi = phys.pi eta = phys.eta kT = phys.kT gamma = abs(F[dim - 1] / v0) gamma0 = 6. * pi * eta * r * 1e-9 print "gamma (simulation):", gamma print "gamma (stokes law):", gamma0 print D = kT / gamma D0 = kT / gamma0 print "D (simulation):", D print "D (stokes law):", D0 print "Reducing factor due to confinement:", D / D0 return D / D0
VVV = dolfin.TensorFunctionSpace(meshp, "CG", 1, shape=(dim, dim)) D = dolfin.Function(VVV) v2d = dolfin.vertex_to_dof_map(VVV) Dv = D.vector() for k, (i, j) in enumerate(product(i3, i3)): Dv[np.ascontiguousarray(v2d[k::dim**2])] = np.ascontiguousarray(Da[:, i, j]) setup.phys.update(Dp=D, Dm=D) #embed() return D # set up domain with protein ddata = dict(name="Dpugh", r=0.11, dim=2) setup = pugh.Setup(x0=[0., 0., 10.], dim=2, h=1., Nmax=1e5, diamPore=6. * np.sqrt(np.pi) / 2., cheapest=True, diffusivity_data=ddata) plotter = pugh.Plotter(setup) pugh.prerefine(setup, True) print "getting D" D = set_D_with_protein(setup) print "plotting" plotter.plot(D[0, 0], title="Dxx") dolfin.interactive()
def prerefine(self, visualize=False): return prerefine(self, visualize=visualize)
fz = interp1d(z, Dz) fn = interp1d(x, Dn) ft = interp1d(x, Dt) import matplotlib.pyplot as plt plt.plot(z, fz(z), "s-") plt.figure() plt.plot(x, fn(x), "s-") plt.plot(x, ft(x), "s-") # get geometry, prerefine mesh, compute distance function setup = pugh.Setup(dim=params.dim, x0=None, h=params.h, Nmax=params.Nmax, cheapest=True) pugh.prerefine(setup, visualize=True) dist = distance_boundary_from_geo(setup.geo) VV = dolfin.VectorFunctionSpace(setup.geo.mesh, "CG", 1) normal = dolfin.project(dolfin.grad(dist), VV) plotter = pugh.Plotter(setup) plotter.plot_vector(normal, "normal") #functions, mesh = f.get_functions("pugh_distance", h=h) #dist = functions["y"] def transformation(n, Dn, Dt): D = np.diag([Dn, Dt, Dt]) if len(n) == 3 else np.diag([Dn, Dt]) U, S, V = np.linalg.svd(np.matrix(n)) # U, S = 1., |n| # V = orthogonal coordinate basis with n/|n| as first vector