From 023937cbc786dc33765d73663fb4637b20ee2dc2 Mon Sep 17 00:00:00 2001 From: emile Date: Thu, 11 Oct 2018 18:43:49 +0200 Subject: rebuilt main for calculating timesteps --- main.go | 29 +++++++++++++++++++++++------ 1 file 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) + } } -- cgit 1.4.1