Skip to content

Commit 9e4a059

Browse files
committed
Tidy up configuration files. Add TOI561b. Fix doc links? Update tests
1 parent 21b73d8 commit 9e4a059

2 files changed

Lines changed: 83 additions & 11 deletions

File tree

test/runtests.jl

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Pkg.activate(ROOT_DIR)
1010

1111
# Include libraries
1212
using LoggingExtras
13+
using NCDatasets
1314
using AGNI
1415

1516
@info "Begin AGNI tests"
1617

17-
1818
# Prepare
1919
RES_DIR = joinpath(ROOT_DIR,"res/")
2020
OUT_DIR = joinpath(ROOT_DIR,"out/")
@@ -642,7 +642,7 @@ if suite > 9
642642
@info "Pass"
643643
else
644644
@warn "Fail"
645-
display(atmos.flux_u_lw)
645+
show(atmos.flux_u_lw)
646646
failed += 1
647647
end
648648
total += 1
@@ -665,19 +665,18 @@ if suite > 9
665665
@info "Pass"
666666
else
667667
@warn "Fail"
668-
display(atmos.flux_tot)
668+
show(atmos.flux_tot)
669669
failed += 1
670670
end
671671
total += 1
672-
atmosphere.deallocate!(atmos)
673672
@info "--------------------------"
674673
end
675674
end
676675

677-
# -------------
678-
# Run example TOML config file
679-
# -------------
680676
if suite > 15
677+
# -------------
678+
# Run example TOML config file (writes to output folder)
679+
# -------------
681680
@info " "
682681
@info "Testing model with energy-conserving TP solver"
683682
cfg = AGNI.open_config(joinpath(TEST_DIR, "test.toml"))
@@ -691,10 +690,83 @@ if suite > 15
691690
failed += 1
692691
end
693692
total += 1
694-
atmosphere.deallocate!(atmos)
693+
@info "--------------------------"
694+
695+
# -------------
696+
# Compare result from NetCDF
697+
# -------------
698+
@info " "
699+
@info "Testing values from model solution"
700+
701+
# Read result
702+
@debug "ALL DEBUG SUPPRESSED"
703+
with_logger(MinLevelLogger(current_logger(), Logging.Info-200)) do
704+
705+
# open netcdf
706+
ds = Dataset(joinpath(OUT_DIR,"atm.nc"),"r")
707+
708+
# read profiles from netCDF file
709+
arr_o_tmp::Array{Float64,1} = ds["tmpl"][:]
710+
arr_o_flN::Array{Float64,1} = ds["fl_N"][:]
711+
arr_o_flC::Array{Float64,1} = ds["fl_cnvct"][:]
712+
arr_o_Kzz::Array{Float64,1} = ds["Kzz"][:]
713+
714+
# close netcdf
715+
close(ds)
716+
end
717+
@debug "ALL DEBUG RESTORED"
718+
719+
# temperature profile
720+
@info "Temperature..."
721+
arr_e[:] .= [160.5675648884, 171.994064313637, 177.938575310175, 179.113900851404, 179.801478507666, 179.167818376284, 179.40614826252, 181.556769798685, 183.007095076024, 182.624208591575, 183.399201292413, 186.261911326026, 190.412634382101, 195.47048174129, 201.251679339825, 207.654691790094, 214.451046157178, 221.848979602947, 231.737439525989, 246.412351141343, 263.513451113498, 288.073705588398, 320.936573630417, 355.668949498865, 393.166000909574, 430.332142915339, 461.765909449321, 488.839407157943, 516.896086763742, 545.950964338871, 573.226076102865, 596.498543067942, 613.203600564291, 622.65575000879, 627.239385241944, 629.635777119968, 631.102258523775, 631.936413339924, 632.289738849541, 632.396879253831, 632.422477552567, 632.428125540173, 632.429337440917, 632.429439784017, 632.429440335934]
722+
if maximum((arr_e[:] .- arr_o_tmp[:]) ./ arr_e[:]) < rtol + 0.2
723+
@info "Pass"
724+
else
725+
@warn "Fail"
726+
show(arr_o_tmp)
727+
failed += 1
728+
end
729+
total += 1
730+
731+
# radiative flux
732+
@info "Radiative flux..."
733+
arr_e[:] .= [-1.70936355061713e-05, -0.0001848507873774, -2.19587959691125e-05, -3.68052697012899e-05, -1.17535213348674e-05, -9.21098234130113e-06, -2.99803821803835e-05, -4.89456000991595e-05, -1.5358869575266e-05, -1.09188006263139e-05, -3.93173775137257e-05, -0.000354796292072024, -0.00165987941761614, -0.00528027329954739, -0.0158055913856288, -0.0433923529017761, -0.11140604524968, -0.308141836228856, -1.46423434726591, -9.77401066606802, -37.3100359467623, -38.7488777778792, -39.2155408656643, -23.6328050591985, -7.23626887173242, -0.00023511365176887, -0.000176458639629118, -0.000168000405722069, -0.000180597452342113, -0.000171841531511063, -0.000151788906691763, -0.00011949688596502, -7.29475105316624e-05, -3.52666797951429e-05, -1.70943386361699e-05, -1.02762551650315e-05, -6.48362776556333e-06, -3.05875096534569e-06, -9.87984617728532e-07, -2.40686721166353e-07, -5.31945902250514e-08, -1.16863944068938e-08, -1.6438207365123e-08, 1.3533281159821e-09, -1.25751721498093e-05 ]
734+
if maximum((arr_e[:] .- arr_o_flN[:]) ./ arr_e[:]) < rtol + 1e-5
735+
@info "Pass"
736+
else
737+
@warn "Fail"
738+
show(arr_o_flN)
739+
failed += 1
740+
end
741+
total += 1
742+
743+
# convective flux
744+
@info "Convective flux..."
745+
arr_e[:] .= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.70370297292099, 22.4258287268845, 17.7152047690876, 7.20391869209392, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
746+
if maximum((arr_e[:] .- arr_o_flC[:]) ./ arr_e[:]) < rtol + 1e-5
747+
@info "Pass"
748+
else
749+
@warn "Fail"
750+
show(arr_o_flC)
751+
failed += 1
752+
end
753+
754+
755+
# eddy diffusion coefficients
756+
@info "Kzz..."
757+
arr_e[:] .= [343861.803277211, 283750.654425665, 234147.652108032, 193215.846845093, 159439.40985939, 131567.497342447, 108567.927918327, 89588.9578396376, 73927.7383356734, 61004.2869927183, 50340.0092478434, 41539.9745820394, 34278.2910464086, 28286.0364958031, 23341.2995869213, 19260.9617288462, 15893.9156467514, 13115.4694216393, 10822.7287707491, 8930.78656048291, 7369.57843796924, 6081.2881357725, 13638.9561240586, 11895.0041403355, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682, 8254.94954692682]
758+
if maximum((arr_e[:] .- arr_o_Kzz[:]) ./ arr_e[:]) < rtol + 1e-2
759+
@info "Pass"
760+
else
761+
@warn "Fail"
762+
show(arr_o_Kzz)
763+
failed += 1
764+
end
765+
total += 1
695766
@info "--------------------------"
696767
end
697768

769+
698770
# -------------
699771
# Inform at end
700772
# -------------

test/test.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ title = "Unit tests configuration"
2222
[files]
2323
input_sf = "../res/spectral_files/Dayspring/48/Dayspring.sf"
2424
input_star = "blackbody"
25-
output_dir = "out/"
25+
output_dir = "../out/"
2626

2727
[composition]
2828
p_surf = 7000.0
@@ -62,8 +62,8 @@ title = "Unit tests configuration"
6262

6363
[plots]
6464
at_runtime = false
65-
temperature = false
66-
fluxes = false
65+
temperature = true
66+
fluxes = true
6767
contribution = false
6868
emission = false
6969
albedo = false

0 commit comments

Comments
 (0)