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

Commit

Permalink
More tests on Hohmann
Browse files Browse the repository at this point in the history
Attempted implementation of a Cartesian vector propagation. Not only did
this not work well, but it also took me ages. I wanted this because my
simple Hohmann transfer example seems to go hyperbolic. It really should
not be. I now think that I should change the Hohmann implementation to
be a finite burn (wait for the justification... I know this is more
complicated) because then I can use the standard normalization code
without an odd condition. More importantly though, Hohmann only provides
the numerical delta-v. I don't think I'm applying this correctly since
I'm exerting everything on the second component. It should probably be
converted to PQW frame before the thrust.
  • Loading branch information
ChristopherRabotin committed Jan 24, 2017
1 parent 36cedb6 commit b1acdd8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/imd/hw01pb1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func main() {
start := time.Date(2017, 1, 2, 3, 4, 5, 6, time.UTC)
end := start.Add(time.Duration(-1) * time.Second)
sc.LogInfo()
initEarthOrbit := smd.NewOrbitFromOE(smd.Earth.Radius+400, 0.001, 0.01, 10, 10, 36, smd.Earth)
soiEarthOrbit := smd.NewOrbitFromOE(smd.Earth.SOI, 0.001, 0.01, 10, 10, 36, smd.Earth)
initEarthOrbit := smd.NewOrbitFromOE(smd.Earth.Radius+400, 0, 0.01, 10, 10, 36, smd.Earth)
soiEarthOrbit := smd.NewOrbitFromOE(smd.Earth.SOI, 0, 0.01, 10, 10, 36, smd.Earth)
sc.WayPoints = []smd.Waypoint{smd.NewHohmannTransfer(*soiEarthOrbit, nil)}
mss := smd.NewMission(sc, initEarthOrbit, start, end, false, smd.ExportConfig{})
mss := smd.NewMission(sc, initEarthOrbit, start, end, false, smd.ExportConfig{Filename: "Hoh", OE: false, Cosmo: true, Timestamp: false})
mss.Propagate()
}
12 changes: 9 additions & 3 deletions prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,14 @@ func (cl *HohmannΔv) Precompute(o Orbit) {
if !floats.EqualWithinAbs(cl.target.ν, o.ν, angleε) && !floats.EqualWithinAbs(cl.target.ν, o.ν+math.Pi, angleε) && !floats.EqualWithinAbs(cl.target.ν, o.ν-math.Pi, angleε) {
panic(fmt.Errorf("cannot perform Hohmann between orbits with misaligned semi-major axes\nini: %s\ntgt: %s\n", o, cl.target))
}
if !floats.EqualWithinAbs(o.ν, 0, angleε) && !floats.EqualWithinAbs(o.ν, math.Pi, angleε) {
fmt.Printf("[WARNING] Hohmann transfer started neither at apoapsis nor at periapasis (inefficient)\n")
if !floats.EqualWithinAbs(o.e, 0, eccentricityε) {
panic(fmt.Errorf("cannot perform Hohmann from a non elliptical orbit"))
}
if !floats.EqualWithinAbs(cl.target.i, o.i, angleε) {
fmt.Printf("[WARNING] Hohmann transfer requested on non-coplanar orbits:\nOsc: %s\nTgt: %s\n", o, cl.target)
panic(fmt.Errorf("cannot perform Hohmann between non co-planar orbits\nini: %s\ntgt: %s\n", o, cl.target))
}
if !floats.EqualWithinAbs(o.ν, 0, angleε) && !floats.EqualWithinAbs(o.ν, math.Pi, angleε) {
fmt.Printf("[WARNING] Hohmann transfer started neither at apoapsis nor at periapasis (inefficient)\n")
}
rInit := o.GetRNorm()
rFinal := cl.target.GetRNorm()
Expand Down Expand Up @@ -489,5 +492,8 @@ func (cl *HohmannΔv) Control(o Orbit) []float64 {

// NewHohmannΔv defines a new inversion control law.
func NewHohmannΔv(target Orbit) HohmannΔv {
if !floats.EqualWithinAbs(target.e, 0, eccentricityε) {
panic(fmt.Errorf("cannot perform Hohmann to a non elliptical orbit"))
}
return HohmannΔv{target, hohmannCompute, []float64{0, 0, 0}, []float64{0, 0, 0}, time.Duration(-1) * time.Second, 0, newGenericCLFromCL(hohmann)}
}
21 changes: 20 additions & 1 deletion waypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,39 @@ func TestHohmannΔv(t *testing.T) {
ΔvPeriExp := []float64{0.0, 2.457038, 0.0}
tofExp := time.Duration(5)*time.Hour + time.Duration(15)*time.Minute + time.Duration(24)*time.Second

assertPanic(t, func() {
target.e = 0.5
NewHohmannTransfer(target, nil)
})
target.e = eccentricityε

wp := NewHohmannTransfer(target, nil)
initDT := time.Date(2017, 1, 20, 12, 13, 14, 15, time.UTC)
coastDT := initDT.Add(tofExp / 2)
apoDT := initDT.Add(tofExp + StepSize)
postDT := apoDT.Add(StepSize)

// Test panics
assertPanic(t, func() {
oscul.ν = math.Pi
wp.ThrustDirection(oscul, initDT)
})
// Reset true anomaly after panic test
oscul.ν = math.Pi / 2

assertPanic(t, func() {
oscul.e = 0.5
wp.ThrustDirection(oscul, initDT)
})
// Reset true anomaly after panic test
oscul.e = eccentricityε

assertPanic(t, func() {
oscul.i = math.Pi / 4
wp.ThrustDirection(oscul, initDT)
})
// Reset true anomaly after panic test
oscul.i = angleε

for i := 0; i < 5; i++ {
ctrl, cleared := wp.ThrustDirection(oscul, initDT)
if cleared {
Expand Down

0 comments on commit b1acdd8

Please sign in to comment.