Skip to content

Commit

Permalink
add test for new json format
Browse files Browse the repository at this point in the history
  • Loading branch information
archermarx committed Jun 5, 2024
1 parent 17f3b49 commit 27c83f9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ run
!test/unit_tests/bfield_spt100.csv
!test/unit_tests/input_twozone.json
!test/unit_tests/input_shifted.json
!test/unit_tests/input_newoptions.json
4 changes: 2 additions & 2 deletions src/simulation/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function run_simulation(json_content::JSON3.Object; verbose = true)
apply_thrust_divergence_correction = get_key(json_content, :apply_thrust_divergence_correction, true)

# neutral ingestion multiplier
neutral_ingestion_multiplier = get_key(json_content, :neutral_ingestion_multiplier, 1.0)
neutral_ingestion_multiplier::Float64 = get_key(json_content, :neutral_ingestion_multiplier, 1.0)

# Optional parameters for pressure-dependent models
if anom_model == "ShiftedTwoZone" || anom_model == "ShiftedTwoZoneBohm" ||
Expand Down Expand Up @@ -105,7 +105,7 @@ function run_simulation(json_content::JSON3.Object; verbose = true)
anode_mass_flow_rate = anode_mass_flow_rate,
cathode_potential = cathode_potential,
ncharge = max_charge,
wall_loss_model = WallSheath(eval(Symbol(wall_material)), sheath_loss_coefficient),
wall_loss_model = WallSheath(eval(Symbol(wall_material)), Float64(sheath_loss_coefficient)),
ion_wall_losses = ion_wall_losses,
cathode_Te = cathode_electron_temp_eV,
LANDMARK = false,
Expand Down
39 changes: 39 additions & 0 deletions test/unit_tests/input_newoptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"neutral_temp_K": 300,
"neutral_velocity_m_s": 496.3740879117346,
"ion_temp_K": 1000,
"cathode_electron_temp_eV": 4.052826236115989,
"sheath_loss_coefficient": 1.0,
"inner_outer_transition_length_m": 0.012536903207365219,
"anom_model_coeffs": [
0.01547448060114236,
0.9533713984302014
],
"background_pressure_Torr": 8.049041434341745e-07,
"background_temperature_K": 300,
"neutral_ingestion_multiplier": 1.0,
"apply_thrust_divergence_correction": false,
"thruster_name": "SPT-100",
"inner_radius": 0.035,
"outer_radius": 0.05,
"channel_length": 0.025,
"magnetic_field_file": "unit_tests/bfield_spt100.csv",
"wall_material": "BNSiO2",
"magnetically_shielded": false,
"anode_potential": 360.31297211799335,
"cathode_potential": 56.016278898671885,
"anode_mass_flow_rate": 5.521416599601767e-06,
"propellant": "Xenon",
"num_cells": 100,
"dt_s": 1.25e-08,
"duration_s": 0.002,
"num_save": 1000,
"cathode_location_m": 0.08,
"max_charge": 1,
"flux_function": "rusanov",
"limiter": "van_leer",
"reconstruct": true,
"ion_wall_losses": true,
"electron_ion_collisions": true,
"anom_model": "TwoZoneBohm"
}
6 changes: 6 additions & 0 deletions test/unit_tests/test_json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@
@test config.anom_model isa HallThruster.TwoZoneBohm
@test config.anom_model.coeffs[1] 1/160
@test config.anom_model.coeffs[2] 1/16

json_path = joinpath(test_path, "input_newoptions.json")
sol = HallThruster.run_simulation(json_path)
config = sol.params.config
@test config.neutral_ingestion_multiplier == 1.0
@test config.apply_thrust_divergence_correction == false
end

0 comments on commit 27c83f9

Please sign in to comment.