diff --git a/src/AGNI.jl b/src/AGNI.jl index 0c95329a..d5d71ab0 100755 --- a/src/AGNI.jl +++ b/src/AGNI.jl @@ -68,7 +68,7 @@ module AGNI # Setup file logger if to_file - logger_file = FormatLogger(outpath; append=true) do io, args + logger_file = FormatLogger(outpath; append=false) do io, args if args.level == LoggingExtras.Info level = "INFO" elseif args.level == LoggingExtras.Warn diff --git a/src/atmosphere.jl b/src/atmosphere.jl index 111c6a29..e4fc09bf 100644 --- a/src/atmosphere.jl +++ b/src/atmosphere.jl @@ -254,7 +254,7 @@ module atmosphere - `mf_path::String` path to file containing VMRs at each level. Optional arguments: - - `condensates::Array{String,1}` list of condensates (gas names). + - `condensates` list of condensates (gas names). - `surface_material::String` surface material (default is "blackbody", but can point to file instead). - `albedo_s::Float64` grey surface albedo used when `surface_material="blackbody"`. - `tmp_floor::Float64` temperature floor [K]. @@ -285,9 +285,9 @@ module atmosphere zenith_degrees::Float64, tmp_surf::Float64, gravity::Float64, radius::Float64, nlev_centre::Int, p_surf::Float64, p_top::Float64, - mf_dict::Dict{String, Float64}, mf_path::String; + mf_dict, mf_path::String; - condensates::Array{String,1} = String[], + condensates = String[], surface_material::String = "blackbody", albedo_s::Float64 = 0.0, tmp_floor::Float64 = 2.0, @@ -925,6 +925,7 @@ module atmosphere # Setup spectral file socstar::String = "" if !isempty(stellar_spectrum) + @debug "Inserting stellar spectrum" if !isfile(stellar_spectrum) @error "Stellar spectrum file '$(stellar_spectrum)' does not exist" diff --git a/src/energy.jl b/src/energy.jl index 3735fe39..f4132ee8 100644 --- a/src/energy.jl +++ b/src/energy.jl @@ -355,7 +355,7 @@ module energy - `pmin::Float64` pressure [bar] below which convection is disabled - `mltype::Int` mixing length value (1: scale height, 2: asymptotic) """ - function mlt!(atmos::atmosphere.Atmos_t; pmin::Float64=1.0e-9, mltype::Int=2) + function mlt!(atmos::atmosphere.Atmos_t; pmin::Float64=1.0e-4, mltype::Int=2) pmin *= 1.0e5 # convert bar to Pa diff --git a/src/plotting.jl b/src/plotting.jl index cd33b50c..b8599e5b 100644 --- a/src/plotting.jl +++ b/src/plotting.jl @@ -271,21 +271,21 @@ module plotting # LW component if atmos.is_out_lw - plot!(plt, _symlog.(-1.0*atmos.flux_d_lw), arr_P, lw=w, lc=col_r, ls=:dash, linealpha=alpha) - plot!(plt, _symlog.( atmos.flux_u_lw), arr_P, lw=w, lc=col_r, ls=:dash, linealpha=alpha) + plot!(plt, _symlog.(-1.0*atmos.flux_d_lw), arr_P, lw=w, lc=col_r, ls=:dash, linealpha=alpha) + plot!(plt, _symlog.( atmos.flux_u_lw), arr_P, lw=w, lc=col_r, ls=:dash, linealpha=alpha) end # SW component if atmos.is_out_sw - plot!(plt, _symlog.(-1.0.*atmos.flux_d_sw), arr_P, lw=w, lc=col_r, ls=:dot, linealpha=alpha) - plot!(plt, _symlog.( atmos.flux_u_sw), arr_P, lw=w, lc=col_r, ls=:dot, linealpha=alpha) + plot!(plt, _symlog.(-1.0.*atmos.flux_d_sw), arr_P, lw=w, lc=col_r, ls=:dot, linealpha=alpha) + plot!(plt, _symlog.( atmos.flux_u_sw), arr_P, lw=w, lc=col_r, ls=:dot, linealpha=alpha) end # Net radiative fluxes if atmos.is_out_lw && atmos.is_out_sw - plot!(plt, _symlog.( atmos.flux_u), arr_P, lw=w, lc=col_r, ls=:solid, linealpha=alpha) - plot!(plt, _symlog.(-1.0.*atmos.flux_d), arr_P, lw=w, lc=col_r, ls=:solid, linealpha=alpha) - plot!(plt, _symlog.( atmos.flux_n), arr_P, lw=w, lc=col_n, ls=:solid, linealpha=alpha) + plot!(plt, _symlog.( atmos.flux_u), arr_P, lw=w, lc=col_r, ls=:solid, linealpha=alpha) + plot!(plt, _symlog.(-1.0.*atmos.flux_d), arr_P, lw=w, lc=col_r, ls=:solid, linealpha=alpha) + plot!(plt, _symlog.( atmos.flux_n), arr_P, lw=w, lc=col_n, ls=:solid, linealpha=alpha) end # Convective flux (MLT) diff --git a/src/solver.jl b/src/solver.jl index 05c96c12..57d9f513 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -87,6 +87,7 @@ module solver - `ls_method::Int` linesearch algorithm (0: None, 1: golden, 2: backtracking) - `easy_start::Bool` improve convergence by introducing convection and phase change gradually - `perturb_all::Bool` always recalculate entire Jacobian matrix? Otherwise updates columns only as required + - `ls_increase::Bool` factor by which the cost can increase from last step before triggering linesearch - `detect_plateau::Bool` assist solver when it is stuck in a region of small dF/dT - `modplot::Int` iteration frequency at which to make plots - `save_frames::Bool` save plotting frames @@ -107,6 +108,7 @@ module solver max_steps::Int=400, max_runtime::Float64=900.0, fdw::Float64=3.0e-5, fdc::Bool=true, fdo::Int=2, method::Int=1, ls_method::Int=1, easy_start::Bool=false, + ls_increase::Float64=1.08, detect_plateau::Bool=true, perturb_all::Bool=false, modplot::Int=1, save_frames::Bool=true, modprint::Int=1, plot_jacobian::Bool=false, @@ -139,7 +141,7 @@ module solver tmp_pad::Float64 = 10.0 # do not allow the solver to get closer than this to tmp_floor # easy_start - easy_incr::Float64 = 1.7 # Factor by which to increase easy_sf at each step + easy_incr::Float64 = 2.0 # Factor by which to increase easy_sf at each step easy_trig::Float64 = 0.1 # Increase sf when cost*easy_trig satisfies convergence # finite difference @@ -150,7 +152,6 @@ module solver # linesearch ls_tau::Float64 = 0.7 # backtracking downscale size - ls_increase::Float64 = 1.2 # factor by which cost can increase ls_max_steps::Int = 20 # maximum steps ls_min_scale::Float64 = 1.0e-5 # minimum scale @@ -560,8 +561,8 @@ module solver fill!(perturb, true) for i in 3:arr_len-4 perturb[i] = (sum(abs.(r_cur[i-2:i+2])) > perturb_crit) || - any(atmos.mask_l[i-1:i+1]) || - any(atmos.mask_c[i-1:i+1]) + any(atmos.mask_l[i-2:i+2]) || + any(atmos.mask_c[i-2:i+2]) end end @@ -659,8 +660,8 @@ module solver # Yes, we do need to do linesearch... stepflags *= "Ls-" - - if ls_method == 1 + + if (ls_method == 1) || (ls_cost*0.1 < conv_atol + conv_rtol * c_max) # Use golden-section search method ls_alpha = gs_search(_ls_func, ls_min_scale, ls_alpha, 1.0e-9, ls_min_scale, ls_max_steps)