I’m exploring a simple orbital simulation approach in Go using a constant position–momentum parameter derived from the so-called NKTg Law, where:
p = m * v
C = x * p
From this, we derive:
v = C / (x * m)
So velocity is computed from position, mass, and a constant.
I used real orbital distances for Mercury (2025) as input and compared reconstructed velocity with reference values.
Dataset (2025)
| Date | Position x (m) | Reference Velocity (m/s) |
|---|---|---|
| 1/1/2025 | 5.16e10 | 53400 |
| 4/1/2025 | 6.97e10 | 38900 |
| 7/1/2025 | 5.49e10 | 50400 |
| 10/1/2025 | 6.83e10 | 39800 |
| 12/31/2025 | 4.61e10 | 58900 |
Used constants:
C = 8.90e38
mass = 3.301e23
Go Implementation
Here is a simple Go program that reconstructs the velocity for each data point and computes relative error:
package main
import (
"fmt"
"math"
)
type MercuryData struct {
Date string
X float64
VNASA float64
}
func computeVelocity(C, x, m float64) float64 {
return C / (x * m)
}
func computeRelativeError(vModel, vNASA float64) float64 {
return (vModel - vNASA) / vNASA * 100
}
func computeNKTg2(dmDt, m, v float64) float64 {
p := m * v
return dmDt * p
}
func main() {
C := 8.90e38
mass := 3.301e23
dmDt := -0.5
dataSet := []MercuryData{
{"1/1/2025", 5.16e10, 53400},
{"4/1/2025", 6.97e10, 38900},
{"7/1/2025", 5.49e10, 50400},
{"10/1/2025", 6.83e10, 39800},
{"12/31/2025", 4.61e10, 58900},
}
fmt.Println("NKTg Law Mercury Orbit Simulation (Go)\n--------------------------------------------------")
for _, d := range dataSet {
vModel := computeVelocity(C, d.X, mass)
relErr := computeRelativeError(vModel, d.VNASA)
nktg2 := computeNKTg2(dmDt, mass, vModel)
fmt.Printf("Date: %s\n", d.Date)
fmt.Printf("Position (m): %g\n", d.X)
fmt.Printf("Reconstructed Velocity: %g m/s\n", vModel)
fmt.Printf("Reference Velocity: %g m/s\n", d.VNASA)
fmt.Printf("Relative Error: %.4f %%\n", relErr)
fmt.Printf("NKTg2: %g\n", nktg2)
fmt.Println("--------------------------------------------------")
}
fmt.Println("Done.")
_ = math.E // suppress unused import if needed
}
Discussion Points
I’d appreciate feedback on the following:
-
Is using a constant parameter model like
C = x * (m * v)in a real simulation reasonable? -
Should we normalize values before computing to improve numerical precision?
-
Would you suggest structuring this as a reusable module or library?
-
Any suggestions for expanding the simulation into a full multi-body orbit engine?
Thanks in advance for insights and suggestions!