コード例 #1
0
            "using neumann ( Effective Transpiration = " + str(eff_trans) +
            " m^3 s^-1)", "top potential", x[0])

    if dirichlet or (x[0] < top_pot):
        Q, b = xylem_flux.linear_system(seg, nodes, radius, kr, kz, rho, g,
                                        soil_p2)
        dirichlet = True
        Q, b = xylem_flux.bc_dirichlet(Q, b, np.array([0]),
                                       np.array([top_pot]))
        x = LA.spsolve(Q, b)  # direct
        eff_trans = xylem_flux.axial_flux0(x, seg, nodes, kz, rho, g)
        dirichlet = eff_trans < pot_trans
        print("using dirichlet ( Effective Transpiration = " + str(eff_trans) +
              " m^3 s^-1)")

    radial_flux = xylem_flux.radial_flux(
        x, seg, nodes, radius, kr, soil_p2)  # used to calculate the sink term
    # print("Minimal xylem potential", min(x), " Maximal xylem potential ", max(x))

    #
    # 4. Sink term
    #
    t4 = timer.time()
    # print("4 . Apply sink")
    sink = np.zeros(inf.n)
    for i in range(0, len(seg)):
        z1 = nodes[seg[i, 0], 2]
        z2 = nodes[seg[i, 1], 2]
        z = 0.5 * (z1 + z2)
        if z > -1:
            ind = math.floor(-z / soil[-1].lowerDepth * inf.n)
            sink[ind] += radial_flux[i] * dt
コード例 #2
0
ファイル: example5a.py プロジェクト: xiaoranzhou/CPlantBox
kz = np.vstack((shoot1, kz))

# Call back function for soil potential
soil = lambda x, y, z : soil_psi

# Calculate fluxes within the root system
Q, b = xylem_flux.linear_system(seg, nodes, radius, kr, kz, rho, g, soil)
# plt.spy(Q)
# plt.show()
Q, b = xylem_flux.bc_neumann(Q, b, np.array([0]), np.array([pot_trans]))

start = timeit.default_timer()
x = LA.spsolve(Q, b, use_umfpack = True)  # direct
stop = timeit.default_timer()
print ("linear system solved in", stop - start, " s")

# Save results into vtp
segP = nodes2seg(nodes, seg, x)  # save vtp
axial_flux = xylem_flux.axial_flux(x, seg, nodes, kz, rho, g)
radial_flux = xylem_flux.radial_flux(x, seg, nodes, radius, kr, soil)
net_flux = axial_flux + radial_flux

rs_ana.addUserData(a2v(segP[sseg.shape[0]:]), "pressure")
rs_ana.addUserData(a2v(axial_flux[sseg.shape[0]:]), "axial_flux")
rs_ana.addUserData(a2v(radial_flux[sseg.shape[0]:]), "radial_flux")
rs_ana.addUserData(a2v(net_flux[sseg.shape[0]:]), "net_flux")

rs_ana.write("results/example_5a.vtp")

print("done.")