Exemple #1
0
func main() {
	p := &ode.IVP{
		System:       system.Gravity,
		From:         0,
		To:           5402.582703094263 * 16,
		InitialValue: []float64{-1814.0, -3708.0, 5153.0, 6.512, -4.229, -0.744},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps)
}
Exemple #2
0
func main() {
	p := &ode.IVP{
		System:       system.Rigid,
		From:         0,
		To:           12,
		InitialValue: []float64{0, 1, 1},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps)
}
Exemple #3
0
func main() {
	sys := &system.VanDerPol{1000}
	p := &ode.IVP{
		System:       sys.Func,
		From:         0,
		To:           3000,
		InitialValue: []float64{2, 0},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps)
}
Exemple #4
0
func main() {
	p := &ode.IVP{
		System:       system.Arenstorf,
		From:         0,
		To:           18,
		InitialValue: []float64{0.994, 0, 0, -2.00158510637908252240537862224},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	// r, err := ode.IntegrateAdaptive(p, s, ode.NewBS45())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps, r.SystemEvaluations)
}
Exemple #5
0
func main() {
	lorenz := &system.Lorenz{8 / 3.0, 10, 28}
	eta := math.Sqrt(lorenz.Beta * (lorenz.Rho - 1))
	p := &ode.IVP{
		System:       lorenz.Func,
		From:         0,
		To:           100,
		InitialValue: []float64{lorenz.Rho - 1, eta, eta + 3},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	// r, err := ode.IntegrateConst(p, 0.01, s, &ode.RK23{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps)
}
Exemple #6
0
func main() {
	p := &ode.IVP{
		System: system.Pleiades,
		From:   0,
		To:     3,
		InitialValue: []float64{3.0, 3.0, -1.0, -3.0, 2.0, -2.0, 2.0, 3.0,
			-3.0, 2.0, 0.0, 0.0, -4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.75,
			-1.5, 0.0, 0.0, 0.0, -1.25, 1.0, 0.0, 0.0,
		},
	}
	s := ode.DefaultSettings()
	s.Recorder = &printer{}
	r, err := ode.IntegrateAdaptive(p, s, ode.NewDOPRI45())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Time, r.Y, r.Runtime, r.AcceptedSteps, r.RejectedSteps)
}