Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Add RLA and DLA to output file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Apr 28, 2017
1 parent 972a6fb commit 45ab8e6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
42 changes: 42 additions & 0 deletions cmd/designer/finalprj-neptune-final.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[general]
fileprefix = "prj-final"
outputdir = "outputs"
verbose = true
step = "24h"
flybyplanets = "Venus Earth Jupiter"

[launch]
planet = "Earth"
from = 2461283.500
until = 2461284.500
resolution = 1
maxC3 = 13

[arrival]
planet = "Neptune"
from = 2469366.484
until = 2469369.484
maxVinf = 7

[flyby.Venus]
position = 1
from = 2461461.500
until = 2461462.500
deltaV = 0.2
periapsis = 1.01

[flyby.Earth]
position = 2
deltaV = 0.2
from = 2461767.500
until = 2461768.500
periapsis = 1.01
resonant = true
resonance = 2 # TODO: Check with a 3:1 resonance

[flyby.Jupiter]
position = 3
deltaV = 0.2
from = 2463434.443
until = 2463435.443
periapsis = 1.5
20 changes: 10 additions & 10 deletions cmd/designer/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (

// Result stores a full valid result.
type Result struct {
launch time.Time
c3 float64
flybys []GAResult
arrival time.Time
vInf float64
launch time.Time
c3, rla, dla float64
flybys []GAResult
arrival time.Time
vInf float64
}

// CSV returns the CSV of this result
func (r Result) CSV() string {
rtn := fmt.Sprintf("%.3f (%s),%f,", julian.TimeToJD(r.launch), r.launch.Format(dateFormat), r.c3)
rtn := fmt.Sprintf("%.3f (%s),%f,%f,%f,", julian.TimeToJD(r.launch), r.launch.Format(dateFormat), r.c3, r.rla, r.dla)
for _, flyby := range r.flybys {
rtn += flyby.CSV()
}
Expand All @@ -30,7 +30,7 @@ func (r Result) CSV() string {

//Clone figure it out
func (r Result) Clone() Result {
newResult := Result{r.launch, r.c3, nil, r.arrival, r.vInf}
newResult := Result{r.launch, r.c3, r.rla, r.dla, nil, r.arrival, r.vInf}
newResult.flybys = make([]GAResult, len(r.flybys))
for i, fb := range r.flybys {
newResult.flybys[i] = fb
Expand All @@ -39,8 +39,8 @@ func (r Result) Clone() Result {
}

// NewResult initializes a result.
func NewResult(launch time.Time, c3 float64, numGA int) Result {
return Result{launch, c3, make([]GAResult, numGA), time.Now(), -1}
func NewResult(launch time.Time, c3, rla, dla float64, numGA int) Result {
return Result{launch, c3, rla, dla, make([]GAResult, numGA), time.Now(), -1}
}

// GAResult stores the result of a gravity assist.
Expand Down Expand Up @@ -68,7 +68,7 @@ func StreamResults(prefix string, planets []smd.CelestialObject, rsltChan <-chan
if err != nil {
panic(err)
}
hdrs := "launch,c3,"
hdrs := "launch,c3,rla,dla,"
for pNo, planet := range planets[0 : len(planets)-1] {
hdrs += planet.Name + "DT,"
hdrs += planet.Name + "DV,"
Expand Down
9 changes: 7 additions & 2 deletions cmd/designer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func main() {
if verbose {
log.Printf("[info] searching for %s -> %s", launch.planet.Name, flybys[0].planet.Name)
}
c3Map, tofMap, _, _, vInfArriVecs := smd.PCPGenerator(launch.planet, flybys[0].planet, launch.from, launch.until, flybys[0].from, flybys[0].until, 24/timeStep.Hours(), 24/timeStep.Hours(), smd.TTypeAuto, true, ultraDebug, false)
c3Map, tofMap, _, vInfDepVecs, vInfArriVecs := smd.PCPGenerator(launch.planet, flybys[0].planet, launch.from, launch.until, flybys[0].from, flybys[0].until, 24/timeStep.Hours(), 24/timeStep.Hours(), smd.TTypeAuto, true, ultraDebug, false)
if *cpuprofile != "" {
return
}
Expand Down Expand Up @@ -159,8 +159,13 @@ func main() {
continue
}
// Fulfills the launch requirements.
// Print the DLA and RLA
vInfDepatureVec := vInfDepVecs[launchDT][arrivalIdx]
rla := smd.Rad2deg(math.Atan2(vInfDepatureVec.At(0, 0), vInfDepatureVec.At(1, 0)))
dla := smd.Rad2deg(math.Asin(vInfDepatureVec.At(2, 0)))
fmt.Printf("RLA = %f deg\tDLA = %f \n", rla, dla)
vInfIn := []float64{vInfInVec.At(0, 0), vInfInVec.At(1, 0), vInfInVec.At(2, 0)}
prevResult := NewResult(launchDT, c3, len(planets)-1)
prevResult := NewResult(launchDT, c3, rla, dla, len(planets)-1)
wg.Add(1)
cpuChan <- true
go GAPCP(arrivalDT, flybys[0], 0, vInfIn, prevResult)
Expand Down

0 comments on commit 45ab8e6

Please sign in to comment.