Ejemplo n.º 1
0
def velocities(X, **params):
    v0, v1 = [], []
    for x0 in X:
        setup = Howorka.Setup(x0=x0, **params)
        f, v, dv = velocity_iteration(setup, 6)
        assert np.linalg.norm(1e12*f[-1]) < 1e-3
        #assert np.linalg.norm(dv[-1]) < 1e-3*np.linalg.norm(dv[0])
        v0.append(list(v[0]))
        v1.append(list(v[-1]))
    return dict(v0=v0, v1=v1)
Ejemplo n.º 2
0
def nonzero_velocities_2D(V, **params):
    setup = Howorka.Setup(**params)
    gamma = friction(setup)
    print "friction gamma", gamma
    # determine F(0), only once
    if not 0. in V:
        V.append(0.)
        V.sort()

    F = [None]*len(V)
    i0 = V.index(0.)
    F[i0] = velo2force_2D(0., setup)
    F0 = F[i0]
    print "F(0)", F0

    for i, v in enumerate(V):
        if not i == i0:
            print "\n--- Velocity %d ---" %(i+1,)
            F[i] = velo2force_2D(v, setup)
            print "Velocity", v
            print "Force (exact)", F[i]
            print "Force (linear)", F0 - gamma*v

    return F, gamma, F0
Ejemplo n.º 3
0
    F0 = F[i0]
    print "F(0)", F0

    for i, v in enumerate(V):
        if not i == i0:
            print "\n--- Velocity %d ---" %(i+1,)
            F[i] = velo2force_2D(v, setup)
            print "Velocity", v
            print "Force (exact)", F[i]
            print "Force (linear)", F0 - gamma*v

    return F, gamma, F0

params = user_params(dim=3, Nmax=1.5e5, h=1., dnaqsdamp=0.25,
                     x0=[0.2,0.,4.01], Qmol=-1., bulkcon=300.)
setup = Howorka.Setup(**params)
setup.prerefine()
velo2force_3D([0., 0.1, 0.2], setup)

do_v2f = False
redo_v2f = False
if do_v2f:
    if redo_v2f:
        params = user_params(dim=2, Nmax=2e4, h=.5, dnaqsdamp=0.25,
                             x0=[0.,0.,4.5], Qmol=-1., bulkcon=300.)
        V = list(np.linspace(-1., 1., 3))
        F, gamma, F0 = nonzero_velocities_2D(V, **params)
        fields.save_entries("howorka_velo2force_3", params, V=V, F=F, gamma=gamma, F0=F0)
        fields.update()

    dolfin.interactive()