Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
archermarx committed May 25, 2024
1 parent 9033a1b commit 1b3cc5c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/HallThruster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function example_simulation(;ncells, duration, dt, nsave)
HallThruster.current_eff(sol_1)
HallThruster.divergence_eff(sol_1)
HallThruster.voltage_eff(sol_1)
return sol_1
end

# # Precompile statements to improve load time
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function solve(U, params, tspan; saveat)
integrate_heavy_species!(U, params, params.dt[])
update_heavy_species!(U, params)

# Check for NaNs and terminate if necessary
# Check for NaNs in heavy species solve and terminate if necessary
nandetected = false
infdetected = false

Expand Down
6 changes: 3 additions & 3 deletions src/simulation/update_heavy_species.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ function iterate_heavy_species!(dU, U, params; apply_boundary_conditions = true)
end

# Perform one step of the Strong-stability-preserving RK22 algorithm to the ion fluid
function integrate_heavy_species!(U, params, dt)
function integrate_heavy_species!(U, params, dt, apply_boundary_conditions = true)
(;k, u1) = params.cache

# First step of SSPRK22
iterate_heavy_species!(k, U, params)
iterate_heavy_species!(k, U, params; apply_boundary_conditions)
@. u1 = U + dt * k
stage_limiter!(u1, params)

# Second step of SSPRK22
iterate_heavy_species!(k, u1, params)
iterate_heavy_species!(k, u1, params; apply_boundary_conditions)
@. U = (U + u1 + dt * k) / 2
stage_limiter!(U, params)

Expand Down
5 changes: 3 additions & 2 deletions test/order_verification/ovs_energy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ function verify_energy(ncells; niters = 20000)
ionization_product_indices,
excitation_reactions,
excitation_reactant_indices,
Δz_cell, Δz_edge
Δz_cell, Δz_edge,
ncells
)

solve_energy!(params, niters, dt)
Expand All @@ -177,7 +178,7 @@ function verify_energy(ncells; niters = 20000)
ionization_product_indices,
excitation_reactions,
excitation_reactant_indices,
Δz_cell, Δz_edge
Δz_cell, Δz_edge, ncells
)

solve_energy!(params, niters, dt)
Expand Down
5 changes: 2 additions & 3 deletions test/order_verification/ovs_ions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ function solve_ions(ncells, scheme; t_end = 1e-4)
ionization_reactions = HallThruster._load_reactions(config.ionization_model, species)
index = HallThruster.configure_index(fluids, fluid_ranges)

@show is_velocity_index, fluid_ranges

nvars = fluid_ranges[end][end]

F = zeros(nvars, nedges)
Expand Down Expand Up @@ -150,6 +148,7 @@ function solve_ions(ncells, scheme; t_end = 1e-4)
cache = (;k, u1, ue, μ, F, UL, UR, ∇ϕ, λ_global, channel_area, dA_dz, dt_cell, dt, dt_u, dt_iz, dt_E, nϵ, νiz, inelastic_losses)

params = (;
ncells = ncells+2,
index,
config,
cache,
Expand All @@ -176,7 +175,7 @@ function solve_ions(ncells, scheme; t_end = 1e-4)
t = 0.0
while t < t_end
@views U[:, end] = U[:, end-1]
HallThruster.integrate_heavy_species!(U, params, dt[]);
HallThruster.integrate_heavy_species!(U, params, dt[], false);
t += dt[]
end

Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using SparseArrays

doctest(HallThruster)

# exercise all parts of the solver loop
HallThruster.example_simulation(;ncells=20, duration=1e-7, dt=1e-8, nsave=2)

include("unit_tests/test_gas.jl")
Expand Down
28 changes: 8 additions & 20 deletions test/unit_tests/test_restarts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,22 @@
restart_path = joinpath(test_path, "test_restart.jld2")

config = HallThruster.Config(;
ncharge = 1,
anode_Te = 2.0,
cathode_Te = 2.0,
discharge_voltage = 300.0,
excitation_model = HallThruster.LandmarkExcitationLookup(),
wall_loss_model = HallThruster.WallSheath(HallThruster.BoronNitride, 1.0),
implicit_energy = 1.0,
neutral_velocity = 300.0,
neutral_temperature = 300.0,
ion_temperature = 1000.0,
thruster = HallThruster.SPT_100,
anode_mass_flow_rate = 5e-6,
electron_neutral_model = HallThruster.LandmarkElectronNeutral(),
electron_ion_collisions = true,
ionization_model = HallThruster.LandmarkIonizationLookup(),
domain = (0.0, 0.05),
LANDMARK = true,
conductivity_model = HallThruster.LANDMARK_conductivity(),
domain = (0.0u"cm", 8.0u"cm"),
discharge_voltage = 300.0u"V",
anode_mass_flow_rate = 5u"mg/s",
wall_loss_model = HallThruster.WallSheath(HallThruster.BoronNitride, 0.15)
)

ncells = 50
grid = HallThruster.generate_grid(config.thruster.geometry, config.domain, EvenGrid(ncells))
fluids, fluid_ranges, species, species_range_dict = HallThruster.configure_fluids(config)

#make a new restart from the current configuration
sol = HallThruster.run_simulation(config; dt = 1e-9, duration=4e-9, grid = HallThruster.EvenGrid(ncells), nsave = 10)
duration=1e-7
dt=1e-8
nsave=2
sol = HallThruster.run_simulation(config; ncells, duration, dt, nsave, verbose = false)
HallThruster.write_restart(restart_path, sol)

# Check that writing a restart of a restart does not lose any information
Expand Down Expand Up @@ -56,7 +46,6 @@
@test cache.Tev sol[:Tev][end]
@test cache.νc sol[:νc][end]


#test that a simulation can be run from the restart
restart_sol = HallThruster.run_simulation(config; dt = 5e-9, duration=4e-9, grid = HallThruster.EvenGrid(ncells), nsave = 10, restart = restart_path)
@test restart_sol.retcode == :success
Expand Down Expand Up @@ -95,5 +84,4 @@ end
@test landmark_1[3].u[1][1, :] landmark_1_hybrid.u[1][1, :]
@test landmark_1[3].u[1][2, :] landmark_1_hybrid.u[1][2, :]
@test landmark_1[3].u[1][4, :] landmark_1_hybrid.u[1][4, :]

end

0 comments on commit 1b3cc5c

Please sign in to comment.