about summary refs log tree commit diff
path: root/main.go
blob: 48ed0758253596f813c3d5ace55a3eb58a26fafa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main

import (
	"./csv"
	"./draw"
	"./forces"
	"./structs"
	"fmt"
	"git.darknebu.la/bit/logplus"
)

func main() {
	var threads int = 8
	var frames int = 1
	var stars int = 800

	// the slice starsSlice stores the star structures
	starsSlice := []structs.Star{}

	logplus.LogPositive("Opening the csv")
	starsSlice = csv.Import("data/U_ALL.csv", 0, stars, starsSlice)

	// Simulate the position of the stars after a specific time
	for i := 0; i < frames; i++ {

		// Print the iterator
		logplus.LogPositive("--- --- --- --- ---")
		logplus.LogPositive(fmt.Sprintf("Frames %d/%d", i, frames))

		// Calculate the position of stars after one timestep
		logplus.LogPositive("Calculate the new Star positions")
		starsSlice = forces.NextTimestep(starsSlice, 500000)

		// Calculate all the forces acting inside of the galaxy
		logplus.LogPositive("Calculate the acting forces")
		starsSlice = forces.CalcAllForces(starsSlice, threads)

		// Save the slice
		outputName := fmt.Sprintf("out_%d.png", i+1)
		logplus.LogPositive(fmt.Sprintf("draw the slice and save it to %s\n", outputName))
		draw.Slice(starsSlice, outputName)
	}
}