From 33881a29f68ec4f52ba45d383802c92f47a19d39 Mon Sep 17 00:00:00 2001 From: hanemile Date: Fri, 2 Nov 2018 23:06:59 +0100 Subject: - --- main.go | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 7424965..e831ef3 100644 --- a/main.go +++ b/main.go @@ -1,42 +1,51 @@ package main import ( + "fmt" "git.darknebu.la/GalaxySimulator/Source/csv" "git.darknebu.la/GalaxySimulator/Source/draw" - "git.darknebu.la/GalaxySimulator/Source/forces" + // "git.darknebu.la/GalaxySimulator/Source/forces" "git.darknebu.la/GalaxySimulator/Source/structs" - "fmt" "git.darknebu.la/bit/logplus" - "math" + // "math" + "os" ) func main() { + // Define a logging level for logplus logplus.SetLogLevel(logplus.LevelAll) - var threads int = 8 + + // var threads int = 8 var frames int = 1 var rangeStart int = 0 - var rangeEnd int = 50000 + + // Error handling (panic if there enouth arguments are provided) + if len(os.Args) < 2 { + panic("It seems like you forgot to supply a number of stars!") + } + rangeEnd, _ := os.Args[1] // the slice starsSlice stores the star structures starsSlice := []structs.Star2D{} - logplus.LogNeutral("Opening the csv") + // Import data from a csv + logplus.LogNeutralf("Opening the csv") starsSlice = csv.Import("data/U_ALL.csv", rangeStart, rangeEnd, starsSlice) // Simulate frames for i := 0; i < frames; i++ { - logplus.LogPositive("--- --- --- --- ---") - logplus.LogPositive(fmt.Sprintf("Frames %d/%d", i, frames)) + logplus.LogPositivef("--- --- --- --- ---") + // logplus.LogPositive(fmt.Sprintf("Frames %d/%d", i, frames)) logplus.LogPositive("Done drawing the quadtree") - logplus.LogNeutral("Calculate the new Star positions") - starsSlice = forces.NextTimestep(starsSlice, 25*math.Pow(10, 4+7)) + // logplus.LogNeutral("Calculate the new Star positions") + // starsSlice = forces.NextTimestep(starsSlice, 25*math.Pow(10, 4+7)) - logplus.LogNeutral("Calculate the acting accelerations") - starsSlice = forces.CalcAllAccelerations(starsSlice, threads) + // logplus.LogNeutral("Calculate the acting accelerations") + // starsSlice = forces.CalcAllAccelerations(starsSlice, threads) - outputName := fmt.Sprintf("out_%d.png", i+3) - logplus.LogNeutral(fmt.Sprintf("draw the slice and save it to %s\n", outputName)) + // draw the galaxy + outputName := fmt.Sprintf("out_%d.png", i+4) + logplus.LogNeutralf(fmt.Sprintf("draw the slice and save it to %s", outputName)) draw.Slice(starsSlice, outputName) - } } -- cgit 1.4.1