r.test() # sanity checks nodes = r.get_nodes() cci = picker(nodes[0, 0], nodes[0, 1], nodes[0, 2]) # collar cell index """ Numerical solution """ start_time = timeit.default_timer() x_, y_ = [], [] sx = s.getSolutionHead() # inital condition, solverbase.py N = round(sim_time / dt) t = 0. for i in range(0, N): rx = r.solve(rs_age + t, -trans * sinusoidal(t), sx[cci], sx, True, wilting_point) # xylem_flux.py x_.append(t) y_.append(float(r.collar_flux(rs_age + t, rx, sx))) fluxes = r.soilFluxes(rs_age + t, rx, sx, False) s.setSource(fluxes) # richards.py s.solve(dt) sx = s.getSolutionHead() # richards.py min_sx, min_rx, max_sx, max_rx = np.min(sx), np.min(rx), np.max( sx), np.max(rx) n = round(float(i) / float(N) * 100.) print("[" + ''.join(["*"]) * n + ''.join([" "]) * (100 - n) + "], [{:g}, {:g}] cm soil [{:g}, {:g}] cm root at {:g} days {:g}". format(min_sx, max_sx, min_rx, max_rx, s.simTime, rx[0])) t += dt print("Coupled benchmark solved in ",
simtime = 14 # [day] for task b """ root system """ rs = pb.MappedRootSystem() path = "../../../modelparameter/rootsystem/" name = "Anagallis_femina_Leitner_2010" # Zea_mays_1_Leitner_2010 rs.readParameters(path + name + ".xml") rs.initialize() rs.simulate(simtime, False) """ root problem """ r = XylemFluxPython(rs) r.setKr([kr]) r.setKx([kz]) nodes = r.get_nodes() soil_index = lambda x, y, z: 0 r.rs.setSoilGrid(soil_index) """ Numerical solution """ rx = r.solve_dirichlet(0., p0, p_s, [p_s], True) fluxes = r.segFluxes(simtime, rx, -200 * np.ones(rx.shape), False) # cm3/day print("Transpiration", r.collar_flux(simtime, rx, [p_s]), "cm3/day") """ plot results """ plt.plot(rx, nodes[:, 2], "r*") plt.xlabel("Xylem pressure (cm)") plt.ylabel("Depth (m)") plt.title("Xylem matric potential (cm)") plt.show() """ Additional vtk plot """ ana = pb.SegmentAnalyser(r.rs) ana.addData("rx", rx) ana.addData("fluxes", np.maximum(fluxes, -1.e-3)) # cut off for vizualisation vp.plot_roots(ana, "rx", "Xylem matric potential (cm)") # "fluxes"
cci = picker(nodes[0, 0], nodes[0, 1], nodes[0, 2]) # collar cell index """ Numerical solution """ start_time = timeit.default_timer() x_, y_ = [], [] sx = s.getSolutionHead() # inital condition, solverbase.py N = round(sim_time / dt) t = 0. for i in range(0, N): rs.simulate(dt) rx = r.solve(rs_age + t, -trans * sinusoidal(t), sx[cci], sx, True, wilting_point) # xylem_flux.py x_.append(t) y_.append(float(r.collar_flux(rs_age + t, rx, sx))) # exact root collar flux fluxes = r.soilFluxes(rs_age + t, rx, sx, False) s.setSource(fluxes) # richards.py s.solve(dt) sx = s.getSolutionHead() # richards.py min_sx, min_rx, max_sx, max_rx = np.min(sx), np.min(rx), np.max( sx), np.max(rx) n = round(float(i) / float(N) * 100.) print("[" + ''.join(["*"]) * n + ''.join([" "]) * (100 - n) + "], [{:g}, {:g}] cm soil [{:g}, {:g}] cm root at {:g} days {:g}". format(min_sx, max_sx, min_rx, max_rx, s.simTime, rx[0])) t += dt print("Coupled benchmark solved in ",
soil_index = lambda x, y, z: int(-10 * z ) # maps to p_s (hydrostatic equilibirum) rs.setSoilGrid(soil_index) path = "../../../modelparameter/rootsystem/" name = "Anagallis_femina_Leitner_2010" # Zea_mays_1_Leitner_2010 rs.setSeed(1) rs.readParameters(path + name + ".xml") rs.initialize() rs.simulate(simtime, False) p_s = np.linspace(-200, -400, 2001) # 2 meter down, resolution in mm """ set up xylem parameters """ r = XylemFluxPython(rs) r.setKr([kr]) # or use setKrTables, see XylemFlux.h r.setKx([kz]) """ numerical solution of transpiration -1 cm3/day""" rx = r.solve_neumann( simtime, -1, p_s, True) # True: matric potential given per cell (not per segment) print("solved") fluxes = r.segFluxes(simtime, rx, p_s, False, True) # cm3/day (double simTime, rx, sx, approx, cells print("Transpiration", r.collar_flux(simtime, rx, p_s), np.sum(fluxes), "cm3/day") suf = np.array(fluxes) / -1. # [1] """ Additional vtk plot """ ana = pb.SegmentAnalyser(r.rs) ana.addData("SUF", np.minimum(suf, 1.e-2)) # cut off for vizualisation vp.plot_roots(ana, "SUF", "Soil uptake fraction (cm3 day)") # "fluxes"
rs.getRootSystemParameter().seedPos.z = -0.1 rs.initialize() rs.simulate(simtime, False) """ set up xylem parameters """ r = XylemFluxPython(rs) r.setKr([kr]) # or use setKrTables, see XylemFlux.h r.setKx([kz]) """ numerical solution of transpiration -10000 cm3/day - very high to avoid numerical errors""" rx = r.solve_neumann( simtime, -10000, p_s, True) # True: matric potential given per cell (not per segment) print("solved") fluxes = r.segFluxes(simtime, rx, p_s, False, True) # cm3/day (double simTime, rx, sx, approx, cells print("Transpiration", r.collar_flux(simtime, rx, p_s), np.sum(fluxes), "cm3/day") suf = np.array(fluxes) / -10000. # [1] # # """ vtk plot """ # ana = pb.SegmentAnalyser(r.rs) # ana.addData("SUF", suf) # cut off for vizualisation np.minimum(suf, 1.e-4) # vp.plot_roots(ana, "SUF", "Soil uptake fraction (cm3 day)") # "fluxes" print("Sum of suf", np.sum(suf), "from", np.min(suf), "to", np.max(suf)) """ 2. Equivalent soil water potential """ #nodes = r.get_nodes() p_s = np.linspace(-14000, -10000, 3001) p_s[0:10] = -300 # 3 meter down, resolution in mm, dry with moist top soil_index = lambda x, y, z: int(-10 * z)