-
Notifications
You must be signed in to change notification settings - Fork 2
/
SimulationRunner.java
155 lines (144 loc) · 4.75 KB
/
SimulationRunner.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
* @(#)SimulationRunner.java
*
*
* @author
* @version 1.00 2016/9/14
*/
import java.lang.*;
import java.util.*;
import java.util.Scanner;
public class SimulationRunner {
/**
* Creates a new instance of <code>SimulationRunner</code>.
*/
public SimulationRunner() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String name;
int particleCount, frameCap;
double initialMass, variationMass, diskRadius, randomSpin, spinRatio, variationVel, deltaTime, constantGravity;
Scanner kb = new Scanner(System.in);
System.out.print("Edit advanced settings? (Y/N) : ");
boolean debugSettings = kb.next().equalsIgnoreCase("Y");
kb.nextLine();
System.out.print("Simulation name : ");
name = kb.nextLine();
System.out.print("Number of initial particles (default = 1000) = ");
try
{
particleCount = Integer.parseInt(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 1000.");
particleCount = 1000;
}
System.out.print("Initial particle mass (default = 10.0) = ");
try
{
initialMass = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 10.0.");
initialMass = 10.0;
}
if (debugSettings){
System.out.print("Variation in initial particle mass (default = 5.0) = ");
try
{
variationMass = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to " + initialMass/2.0 + ".");
variationMass = initialMass/2.0;
}
} else {
variationMass = initialMass/2.0;
}
System.out.print("Radius of the initial disk (default = 2.0) = ");
try
{
diskRadius = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 2.0.");
diskRadius = 2.0;
}
System.out.print("Random initial velocity normal to center (default = 0.5) = ");
try
{
randomSpin = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 0.5.");
randomSpin = 0.5;
}
System.out.print("Spin ratio (0 = all clockwise, 1 = all anti-clockwise) = ");
try
{
spinRatio = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 0.5.");
spinRatio = 0.5;
}
if (debugSettings){
System.out.print("Random variation in initial velocity (default = 0) = ");
try
{
variationVel = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 0.");
variationVel = 0;
}
System.out.print("Size of simulation timestep (default = 0.001) = ");
try
{
deltaTime = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 0.001");
deltaTime = 0.001;
}
System.out.print("Gravitational Constant (default = 0.001) = ");
try
{
constantGravity = Double.parseDouble(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 0.001.");
constantGravity = 0.001;
}
System.out.print("Stop simulation after ___ frames have passed without a\n"+
" collision (default = 500000) = ");
try
{
frameCap = Integer.parseInt(kb.next());
}
catch(NumberFormatException nfe)
{
System.out.println("Input was not recognized, defaulting to 50000.");
frameCap = 50000;
}
} else {
variationVel = 0.0;
deltaTime = 0.001;
constantGravity = 0.001;
frameCap = 50000;
}
ParticleInteraction simulationInstance = new ParticleInteraction(name, particleCount, frameCap, initialMass, variationMass, diskRadius, randomSpin, spinRatio, variationVel, deltaTime, constantGravity);
}
}