Skip to content

Commit

Permalink
move lua error around to include ode condition
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbayer committed Jan 8, 2024
1 parent c90d61a commit 44c8132
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/lua-runtime-fastpm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ schema.growth_mode.choices = {
ODE = 'FASTPM_GROWTH_MODE_ODE',
}

-- enforce a<0.00625 (hard coded) when using ODE growth mode
function schema.time_step.action (time_step)
if time_step[1] < 0.00625 then
error("Cannot start the simulation at a<0.00625 when growth_mode=='ODE'.")
end
end

-- enforce Omega_m
function schema.omega_m.action (value)
if value ~= nil then
Expand All @@ -85,32 +78,35 @@ function schema.omega_m.action (value)
end

-- check for bad input
function schema.T_cmb.action (T_cmb)
if T_cmb ~= 0 then
function schema.time_step.action (time_step)
function schema.T_cmb.action (T_cmb)
function schema.growth_mode.action (growth_mode)
if growth_mode ~= 'ODE' then
if T_cmb ~= 0 and growth_mode ~= 'ODE' then
error("For a run with radiation (T_cmb > 0) use growth_mode='ODE' for accurate results.")
end
-- enforce a<0.00625 (hard coded) when using ODE growth mode
if time_step[1] < 0.00625 and growth_mode == 'ODE' then
error("Cannot start the simulation at a<0.00625 when growth_mode=='ODE'.")
end
end
end

function schema.m_ncdm.action (m_ncdm)
if #m_ncdm ~= 0 then
for i=2, #m_ncdm do
if m_ncdm[i] > m_ncdm[1] then
error("Please input the heaviest ncdm particle first.")
function schema.m_ncdm.action (m_ncdm)
if #m_ncdm ~= 0 then
for i=2, #m_ncdm do
if m_ncdm[i] > m_ncdm[1] then
error("Please input the heaviest ncdm particle first.")
end
end
end
function schema.n_shell.action (n_shell)
function schema.ncdm_freestreaming.action (ncdm_freestreaming)
if ncdm_freestreaming and n_shell ~= 0 then
error("For free-streaming ncdm use n_shell = 0 to turn off ncdm particles.")
function schema.n_shell.action (n_shell)
function schema.ncdm_freestreaming.action (ncdm_freestreaming)
if ncdm_freestreaming and n_shell ~= 0 then
error("For free-streaming ncdm use n_shell = 0 to turn off ncdm particles.")
end
end
end
end
function schema.ncdm_matterlike.action (ncdm_matterlike)
if not ncdm_matterlike and T_cmb == 0 then
error("For a run with exact Omega_ncdm, T_cmb > 0 is required.")
function schema.ncdm_matterlike.action (ncdm_matterlike)
if not ncdm_matterlike and T_cmb == 0 then
error("For a run with exact Omega_ncdm, T_cmb > 0 is required.")
end
end
end
end
Expand Down

0 comments on commit 44c8132

Please sign in to comment.