about summary refs log tree commit diff
diff options
context:
space:
mode:
authoremile <hanemile@protonmail.com>2018-10-11 18:43:49 +0200
committeremile <hanemile@protonmail.com>2018-10-11 18:43:49 +0200
commit023937cbc786dc33765d73663fb4637b20ee2dc2 (patch)
tree15e281b214827665994a00ae5b2d3744be51e30a
parenta5cb0ad9b2e4eaf21d7aa33efc1b06e8ca1882ae (diff)
rebuilt main for calculating timesteps
-rw-r--r--main.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/main.go b/main.go
index a86cc7a..939ec0e 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,8 @@ import (
 
 func main() {
 	var threads int = 8
+	var path1 string = "out_0.png"
+	var frames int = 250
 
 	// the slice starsSlice stores the star structures
 	starsSlice := []structs.Star{
@@ -20,15 +22,30 @@ func main() {
 		{structs.Coord{X: 30000, Y: -30000}, structs.Force{0, 0}, 500000000},
 	}
 
-	llog.Good("Opening the csv\n")
-	starsSlice = csv.Import("data/U_ALL.csv", 0, 50000, starsSlice)
+	llog.Good("Opening the csv")
+	starsSlice = csv.Import("data/U_ALL.csv", 0, 25000, starsSlice)
 
-	llog.Good("Calculate the acting forces\n")
+	// Step 1
+	llog.Good("Calculate the acting forces")
 	starsSlice = forces.CalcAllForces(starsSlice, threads)
 
-	path := "out_2.png"
+	llog.Good(fmt.Sprintf("draw the slice and save it to %s\n", path1))
+	draw.Slice(starsSlice, path1)
 
-	llog.Good(fmt.Sprintf("draw the slice and save it to %s\n", path))
-	draw.Slice(starsSlice, path)
+	// Step 2
+	// Simulate the position of the stars after a specific time
+	for i := 0; i < frames; i++ {
+		llog.Great("--- --- --- --- ---")
+		llog.Great(fmt.Sprintf("Frames %d/%d", i, frames))
 
+		llog.Good("Calculate the new Star positions")
+		starsSlice = forces.NextTimestep(starsSlice, 250000)
+
+		llog.Good("Calculate the acting forces")
+		starsSlice = forces.CalcAllForces(starsSlice, threads)
+
+		outputName := fmt.Sprintf("out_%d.png", i+1)
+		llog.Good(fmt.Sprintf("draw the slice and save it to %s\n", outputName))
+		draw.Slice(starsSlice, outputName)
+	}
 }