Minor changes
This commit is contained in:
parent
65c92bcfc1
commit
3c0eec6591
@ -47,9 +47,15 @@ model {
|
||||
scatter(NativeLibrarySpec)
|
||||
}
|
||||
toolChains {
|
||||
visualCpp(VisualCpp) {
|
||||
// Specify the installDir if Visual Studio cannot be located
|
||||
// installDir "C:/Apps/Microsoft Visual Studio 10.0"
|
||||
installDir "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0"
|
||||
}
|
||||
gcc(Gcc) {
|
||||
// Uncomment to use a GCC install that is not in the PATH
|
||||
// path "/usr/bin/gcc"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -131,13 +131,16 @@ public class SimulationManager {
|
||||
}
|
||||
|
||||
private void printStatistics(Counter counter) {
|
||||
output.println();
|
||||
output.println("***RESULT***");
|
||||
output.printf("The total number of events is %d.%n%n", counter.count);
|
||||
|
||||
output.printf("The spectrometer acceptance angle is %g.%n", simulator.thetaPinch * 180 / Math.PI);
|
||||
output.printf("The transport reflection angle is %g.%n", simulator.thetaTransport * 180 / Math.PI);
|
||||
output.printf("The starting energy is %g.%n", initialE);
|
||||
output.printf("The lower energy boundary is %g.%n%n", simulator.eLow);
|
||||
output.printf("The lower energy boundary is %g.%n", simulator.eLow);
|
||||
output.printf("The source density is %g.%n", simulator.gasDensity);
|
||||
|
||||
output.println();
|
||||
output.printf("The total number of ACCEPTED events is %d.%n", counter.accepted);
|
||||
output.printf("The total number of PASS events is %d.%n", counter.pass);
|
||||
output.printf("The total number of REJECTED events is %d.%n", counter.rejected);
|
||||
|
@ -29,7 +29,7 @@ public class Simulator {
|
||||
double eLow = 14000d;//default value
|
||||
double thetaTransport = 24.107064 / 180 * Math.PI;// default value
|
||||
double thetaPinch = 19.481097 / 180 * Math.PI;// default value
|
||||
double gasDensity = 5e18;// m^-3
|
||||
double gasDensity = 5e20;// m^-3
|
||||
double bSource = 0.6;
|
||||
private UnivariateFunction magneticField;
|
||||
|
||||
@ -147,7 +147,7 @@ public class Simulator {
|
||||
// if magnetic field not defined, consider it to be uniform and equal bSource
|
||||
if (magneticField == null) {
|
||||
double deltaZ = deltaL * cos(pos.theta); // direction already included in cos(theta)
|
||||
double z0 = pos.z;
|
||||
// double z0 = pos.z;
|
||||
pos.addZ(deltaZ);
|
||||
pos.l += deltaL;
|
||||
|
||||
@ -375,12 +375,11 @@ public class Simulator {
|
||||
double addZ(double dZ) {
|
||||
this.z += dZ;
|
||||
while (abs(this.z) > SOURCE_LENGTH / 2d && !isFinished()) {
|
||||
checkEndState();
|
||||
if (!isFinished()) {
|
||||
flip();
|
||||
}
|
||||
// reflecting from back wall
|
||||
if (z < 0) {
|
||||
if (theta >= PI - thetaTransport) {
|
||||
setEndState(EndState.REJECTED);
|
||||
}
|
||||
if (isFinished()) {
|
||||
z = -SOURCE_LENGTH / 2d;
|
||||
} else {
|
||||
@ -388,24 +387,6 @@ public class Simulator {
|
||||
z = -SOURCE_LENGTH - z;
|
||||
}
|
||||
} else {
|
||||
if (isFinished()) {
|
||||
z = SOURCE_LENGTH / 2d;
|
||||
} else {
|
||||
// reflecting from forward transport magnet
|
||||
z = SOURCE_LENGTH - z;
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this position is an end state and apply it if necessary. Does not check z position.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void checkEndState() {
|
||||
//accepted by spectrometer
|
||||
if (theta < thetaPinch) {
|
||||
if (colNum == 0) {
|
||||
//counting pass electrons
|
||||
@ -414,17 +395,49 @@ public class Simulator {
|
||||
setEndState(EndState.ACCEPTED);
|
||||
}
|
||||
}
|
||||
if (isFinished()) {
|
||||
z = SOURCE_LENGTH / 2d;
|
||||
} else {
|
||||
// reflecting from forward transport magnet
|
||||
z = SOURCE_LENGTH - z;
|
||||
}
|
||||
}
|
||||
if (!isFinished()) {
|
||||
flip();
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
//through the rear magnetic pinch
|
||||
if (theta >= PI - thetaTransport) {
|
||||
setEndState(EndState.REJECTED);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * Check if this position is an end state and apply it if necessary. Does not check z position.
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// private void checkEndState() {
|
||||
// //accepted by spectrometer
|
||||
// if (theta < thetaPinch) {
|
||||
// if (colNum == 0) {
|
||||
// //counting pass electrons
|
||||
// setEndState(EndState.PASS);
|
||||
// } else {
|
||||
// setEndState(EndState.ACCEPTED);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //through the rear magnetic pinch
|
||||
// if (theta >= PI - thetaTransport) {
|
||||
// setEndState(EndState.REJECTED);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Reverse electron direction
|
||||
*/
|
||||
void flip() {
|
||||
if(theta<0||theta>PI){
|
||||
throw new Error();
|
||||
}
|
||||
theta = PI - theta;
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,10 @@ public class Trapping {
|
||||
Instant startTime = Instant.now();
|
||||
System.out.printf("Starting at %s%n%n", startTime.toString());
|
||||
new SimulationManager()
|
||||
.withParameters(0.6, 3.7, 4.84, 14000d, 4000)
|
||||
.withOutputFile("D:\\Work\\Numass\\trapping\\trap 14, pinch 100A.out")
|
||||
.withParameters(0.6, 3.7, 4.84, 18000d, 4000)
|
||||
.withOutputFile("D:\\Work\\Numass\\trapping\\test1.out")
|
||||
// .withFieldMap(z, b)
|
||||
// .withDensity(5e20)
|
||||
.withDensity(1e19)
|
||||
.simulateAll((int) 1e6);
|
||||
Instant finishTime = Instant.now();
|
||||
System.out.printf("%nFinished at %s%n", finishTime.toString());
|
||||
|
@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
//#include "scatter.h"
|
||||
#define _USE_MATH_DEFINES // for C
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
Loading…
Reference in New Issue
Block a user