Added some better logging

This commit is contained in:
Connor
2021-10-12 01:36:39 -06:00
parent 7727e436e8
commit c7913d2944
6 changed files with 78 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
export Phase, Mission_Guess, Mission, Bad_Mission
export test_phase1, test_phase2
export test_mg
export store
export Vector
struct Phase
@@ -178,3 +179,44 @@ end
Bad_Mission(s::String) = Bad_Mission(s,false)
Bad_Mission(s::Symbol) = Bad_Mission(String(s),false)
function Base.write(io::IO, m::Mission)
write(io, m.sc)
write(io, "Launch Mass: $(m.start_mass)\n")
write(io, "Launch Date: $(m.launch_date)\n")
write(io, "Launch V∞: $(m.launch_v∞)\n")
i = 1
for phase in m.phases
write(io, "Phase $(i):\n")
write(io, "\tPlanet: $(phase.planet.name)\n")
write(io, "\tV∞_in: $(phase.v∞_in)\n")
write(io, "\tV∞_out: $(phase.v∞_out)\n")
write(io, "\ttime of flight: $(phase.tof)\n")
write(io, "\tthrust profile: $(phase.thrust_profile)\n")
i += 1
end
write(io, "\n")
write(io, "Mass Used: $(m.start_mass - prop(m)[7])\n")
write(io, "Launch C3: $(m.launch_v∞ m.launch_v∞)\n")
write(io, "||V∞_in||: $(norm(m.phases[end].v∞_in))\n")
end
function store(m::Union{Mission, Mission_Guess}, filename::AbstractString)
open(filename, "w") do file
write(file, filename)
write(file, "---------------------------\n")
write(file, "\n")
write(file, m)
end
end
function store(ms::Union{Vector{Mission}, Vector{Mission_Guess}}, filename::AbstractString)
open(filename, "w") do file
write(file, filename)
write(file, "\n")
for m in ms
write(file, "---------------------------\n")
write(file, m)
write(file, "\n\n\n")
end
end
end

View File

@@ -1,6 +1,7 @@
export Sc, test_sc, bepi, no_thrust
mutable struct Sc
name::AbstractString
dry_mass::Float64
mass_flow_rate::Float64
max_thrust::Float64
@@ -8,6 +9,16 @@ mutable struct Sc
duty_cycle::Float64
end
const test_sc = Sc(8000., 0.00025/(2000*0.00981), 0.00025, 50, 0.9)
const bepi = Sc(2000., 2*0.00025/(2800*0.00981), 0.00025, 2, 0.9)
const no_thrust = Sc(0., 0.01, 0., 0, 0.)
function Base.write(io::IO, sc::Sc)
write(io, "Spacecraft: $(sc.name)\n")
write(io, "\tdry_mass: $(sc.dry_mass)\n")
write(io, "\tmass_flow_rate: $(sc.mass_flow_rate)\n")
write(io, "\tmax_thrust: $(sc.max_thrust)\n")
write(io, "\tnum_thrusters: $(sc.num_thrusters)\n")
write(io, "\tduty_cycle: $(sc.duty_cycle)\n")
end
const test_sc = Sc("test", 8000., 0.00025/(2000*0.00981), 0.00025, 50, 0.9)
const bepi = Sc("bepi", 2000., 2*0.00025/(2800*0.00981), 0.00025, 2, 0.9)
const no_thrust = Sc("no thrust", 0., 0.01, 0., 0, 0.)