about summary refs log tree commit diff
path: root/main.go
blob: 13de4dce14346a475c0e46cf7e034c367ca25eb0 (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
44
45
46
47
48
49
50
51
package main

import (
	"./csv"
	"./draw"
	"./forces"
	"./llog"
	"./structs"
	"fmt"
)

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{
		{structs.Coord{X: 30000, Y: 30000}, structs.Force{X: 0, Y: 0}, 500000000},
		{structs.Coord{X: -30000, Y: 30000}, structs.Force{X: 0, Y: 0}, 500000000},
		{structs.Coord{X: -30000, Y: 0}, structs.Force{X: 0, Y: 0}, 500000000},
		{structs.Coord{X: 30000, Y: -30000}, structs.Force{X: 0, Y: 0}, 500000000},
	}

	llog.Good("Opening the csv")
	starsSlice = csv.Import("data/U_ALL.csv", 0, 25000, starsSlice)

	// Step 1
	llog.Good("Calculate the acting forces")
	starsSlice = forces.CalcAllForces(starsSlice, threads)

	llog.Good(fmt.Sprintf("draw the slice and save it to %s\n", path1))
	draw.Slice(starsSlice, path1)

	// 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)
	}
}