Skip to content

Commit 7cdb0c5

Browse files
committed
adjust file struct of datatype
1 parent 1f77c26 commit 7cdb0c5

File tree

9 files changed

+54
-143
lines changed

9 files changed

+54
-143
lines changed

Diff for: src/DataType/DataType.jl

+33-11
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@ include("CanopyLayer.jl")
1717
include("Soil.jl")
1818

1919
include("InterTempVars.jl")
20-
include("Radiation.jl")
2120
include("Met.jl")
2221
include("OUTPUT.jl")
23-
include("State.jl")
2422

23+
@with_kw mutable struct Radiation
24+
Rs_o_df::FT = 0.0
25+
Rs_u_df::FT = 0.0
2526

27+
Rs_o_dir::FT = 0.0
28+
Rs_u_dir::FT = 0.0
29+
30+
Rns_o_df::FT = 0.0
31+
Rns_u_df::FT = 0.0
32+
Rns_g_df::FT = 0.0
33+
34+
Rns_o_dir::FT = 0.0
35+
Rns_u_dir::FT = 0.0
36+
Rns_g_dir::FT = 0.0
37+
38+
Rs_df::FT = 0.0
39+
Rs_dir::FT = 0.0
40+
end
2641

2742
@with_kw mutable struct Cpools
2843
Ccd::NTuple{3,Cdouble} = nzero(3)
@@ -36,6 +51,20 @@ include("State.jl")
3651
Cp::NTuple{3,Cdouble} = nzero(3)
3752
end
3853

54+
@with_kw mutable struct State{FT}
55+
"Surface Temperature: [Ts0, Tsn, Tsm0, Tsn1, Tsn2]"
56+
Ts::Vector{FT} = zeros(FT, 5) # 4:8
57+
Tsoil_prev::Vector{FT} = zeros(FT, 6) # 10:15
58+
θ_prev::Vector{FT} = zeros(FT, 6) # 22:27
59+
ice_ratio::Vector{FT} = zeros(FT, 6) # 28:33
60+
61+
Qhc_o::FT = 0.0
62+
m_water::Layer2 = Layer2{FT}() # [15, 18] + 1
63+
m_snow::Layer3 = Layer3{FT}() # [16, 19, 20] + 1
64+
end
65+
66+
export State
67+
3968
# # current not used
4069
# @with_kw mutable struct TSoil
4170
# T_ground::Cdouble = 0.0
@@ -69,14 +98,7 @@ function fill_res!(df::DataFrame, Res::T, k::Int) where {T<:TypeDF}
6998
end
7099

71100

72-
73-
74-
75-
export
76-
Leaf,
77-
Soil, AbstractSoil,
78-
Met, Results, Cpools,
79-
InterTempVars,
80-
OutputET, Radiation
101+
export Leaf, Soil, AbstractSoil,
102+
Met, Results, Cpools, InterTempVars, OutputET, Radiation
81103

82104
export FT, init_dbl

Diff for: src/DataType/InterTempVars.jl

-35
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,6 @@ InterTempLeafs(x0) = InterTempLeafs(; x0)
4040
# end
4141
# end
4242

43-
export SurfaceMass
44-
45-
@with_kw mutable struct SurfaceMass{FT<:AbstractFloat}
46-
ρ_snow::FT = 0.0
47-
prcp_g::FT = 0.0
48-
49-
z_water::FT = 0.0
50-
z_snow::FT = 0.0
51-
52-
perc_snow_o::FT = 0.0 # Xcs_o
53-
perc_snow_u::FT = 0.0 # Xcs_u
54-
perc_snow_g::FT = 0.0 # Xcs_g
55-
56-
perc_water_o::FT = 0.0 # Xcl_o
57-
perc_water_u::FT = 0.0 # Xcl_u
58-
59-
area_snow_o::FT = 0.0 # Ac_snow_o
60-
area_snow_u::FT = 0.0 # Ac_snow_u
61-
62-
pre_mass_water_o::FT = 0.0 # Wcl_o
63-
pre_mass_water_u::FT = 0.0 # Wcl_u
64-
65-
mass_water_o::FT = 0.0 # Wcl_o
66-
mass_water_u::FT = 0.0 # Wcl_u
67-
mass_water_g::FT = 0.0 # Wcl_g
68-
69-
mass_snow_o::FT = 0.0 # Wcs_o
70-
mass_snow_u::FT = 0.0 # Wcs_u
71-
mass_snow_g::FT = 0.0 # Wcs_g
72-
73-
albedo_v_snow::FT = 0.0
74-
albedo_n_snow::FT = 0.0
75-
end
76-
77-
7843

7944
@with_kw mutable struct InterTempVars
8045
Tc_u::Vector{FT} = zeros(MAX_Loop)

Diff for: src/DataType/Met.jl

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ end
2727
# Met(Srad, LR, temp, rh, rain, wind) =
2828
# Met(; Srad, LR, temp, rh, rain, wind)
2929

30-
3130
"""
3231
# Arguments
3332
- `Srad`: W m-2

Diff for: src/DataType/Radiation.jl

-18
This file was deleted.

Diff for: src/DataType/State.jl

-32
This file was deleted.

Diff for: src/DataType/SurfaceMass.jl

-34
This file was deleted.

Diff for: src/Soil/Init_Soil_var_o.jl

+18
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,21 @@ function init_state!(state::State, soil::AbstractSoil, Ta)
3333
state.ice_ratio .= soil.ice_ratio[1:6]
3434
return nothing
3535
end
36+
37+
# function update_state!(state::State, var_n::Vector{Float64})
38+
# Tsoil = state.Tsoil
39+
# var_n[3+1] = Tsoil[1] # Ts0, 3
40+
# var_n[4+1] = Tsoil[2] # Tsn, 4
41+
# var_n[5+1] = Tsoil[3] # Tsm0, 5
42+
# var_n[6+1] = Tsoil[4] # Tsn1, 6
43+
# var_n[7+1] = Tsoil[5] # Tsn1, 7
44+
45+
# var_n[11+1] = state.Qhc_o # Qhc_o, 11, sensible heat flux
46+
47+
# var_n[15+1] = state.m_water.o
48+
# var_n[18+1] = state.m_water.u
49+
50+
# var_n[16+1] = state.m_snow.o
51+
# var_n[19+1] = state.m_snow.u
52+
# var_n[20+1] = state.m_snow.g
53+
# end

Diff for: src/beps_main.jl

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
function besp_main(d::DataFrame, lai::Vector, par::NamedTuple;
2-
version="julia", debug=false, kw...)
3-
1+
function besp_main(d::DataFrame, lai::Vector, par::NamedTuple; version="julia", debug=false, kw...)
42
meteo = Met()
53
mid_res = Results()
64
mid_ET = OutputET()
@@ -30,23 +28,17 @@ function besp_main(d::DataFrame, lai::Vector, par::NamedTuple;
3028
state = zeros(41)
3129
state_n = zeros(41)
3230
end
31+
Ta = d.tem[1]
32+
Init_Soil_var_o(soil, state, Ta, param, par)
3333

34-
init = true
3534
for i = 1:n
3635
jday = d.day[i]
3736
hour = d.hour[i]
38-
3937
_day = ceil(Int, i / 24)
4038
mod(_day, 50) == 0 && (hour == 1) && println("Day = $_day")
4139

4240
_lai = lai[_day] * param[3] / par.clumping # re-calculate LAI & renew clump index
4341
fill_meteo!(meteo, d, i)
44-
45-
if init
46-
Init_Soil_var_o(soil, state, meteo.temp, param, par)
47-
init = false
48-
end
49-
5042
CosZs = s_coszs(jday, hour, par.lat, par.lon) # cos_solar zenith angle
5143

5244
# /***** start simulation modules *****/

Diff for: src/snowpack.jl

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ function snowpack_stage1_jl(Tair::Float64, prcp::Float64,
9292
m_snow.g = max(0.0, m_snow_pre.g + δ_zs * ρ_new) # [kg m-2]
9393

9494
if δ_zs > 0
95-
# 可能导致了ρ_snow的极低。
9695
ρ_snow[] = (ρ_snow[] * z_snow + ρ_new * δ_zs) / (z_snow + δ_zs) # 计算混合密度
9796
else
9897
ρ_snow[] = (ρ_snow[] - 250) * exp(-0.001 * kstep / 3600.0) + 250.0

0 commit comments

Comments
 (0)