Minor changes

This commit is contained in:
darksnake 2016-07-14 16:41:15 +03:00
parent 65c92bcfc1
commit 3c0eec6591
5 changed files with 55 additions and 32 deletions

View File

@ -47,9 +47,15 @@ model {
scatter(NativeLibrarySpec) scatter(NativeLibrarySpec)
} }
toolChains { 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) { gcc(Gcc) {
// Uncomment to use a GCC install that is not in the PATH // Uncomment to use a GCC install that is not in the PATH
// path "/usr/bin/gcc" // path "/usr/bin/gcc"
} }
} }
} }

View File

@ -131,13 +131,16 @@ public class SimulationManager {
} }
private void printStatistics(Counter counter) { 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 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 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 transport reflection angle is %g.%n", simulator.thetaTransport * 180 / Math.PI);
output.printf("The starting energy is %g.%n", initialE); 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 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 PASS events is %d.%n", counter.pass);
output.printf("The total number of REJECTED events is %d.%n", counter.rejected); output.printf("The total number of REJECTED events is %d.%n", counter.rejected);

View File

@ -29,7 +29,7 @@ public class Simulator {
double eLow = 14000d;//default value double eLow = 14000d;//default value
double thetaTransport = 24.107064 / 180 * Math.PI;// default value double thetaTransport = 24.107064 / 180 * Math.PI;// default value
double thetaPinch = 19.481097 / 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; double bSource = 0.6;
private UnivariateFunction magneticField; private UnivariateFunction magneticField;
@ -147,7 +147,7 @@ public class Simulator {
// if magnetic field not defined, consider it to be uniform and equal bSource // if magnetic field not defined, consider it to be uniform and equal bSource
if (magneticField == null) { if (magneticField == null) {
double deltaZ = deltaL * cos(pos.theta); // direction already included in cos(theta) double deltaZ = deltaL * cos(pos.theta); // direction already included in cos(theta)
double z0 = pos.z; // double z0 = pos.z;
pos.addZ(deltaZ); pos.addZ(deltaZ);
pos.l += deltaL; pos.l += deltaL;
@ -375,12 +375,11 @@ public class Simulator {
double addZ(double dZ) { double addZ(double dZ) {
this.z += dZ; this.z += dZ;
while (abs(this.z) > SOURCE_LENGTH / 2d && !isFinished()) { while (abs(this.z) > SOURCE_LENGTH / 2d && !isFinished()) {
checkEndState();
if (!isFinished()) {
flip();
}
// reflecting from back wall // reflecting from back wall
if (z < 0) { if (z < 0) {
if (theta >= PI - thetaTransport) {
setEndState(EndState.REJECTED);
}
if (isFinished()) { if (isFinished()) {
z = -SOURCE_LENGTH / 2d; z = -SOURCE_LENGTH / 2d;
} else { } else {
@ -388,24 +387,6 @@ public class Simulator {
z = -SOURCE_LENGTH - z; z = -SOURCE_LENGTH - z;
} }
} else { } 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 (theta < thetaPinch) {
if (colNum == 0) { if (colNum == 0) {
//counting pass electrons //counting pass electrons
@ -414,17 +395,49 @@ public class Simulator {
setEndState(EndState.ACCEPTED); 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) { // * Check if this position is an end state and apply it if necessary. Does not check z position.
setEndState(EndState.REJECTED); // *
} // * @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 * Reverse electron direction
*/ */
void flip() { void flip() {
if(theta<0||theta>PI){
throw new Error();
}
theta = PI - theta; theta = PI - theta;
} }

View File

@ -15,10 +15,10 @@ public class Trapping {
Instant startTime = Instant.now(); Instant startTime = Instant.now();
System.out.printf("Starting at %s%n%n", startTime.toString()); System.out.printf("Starting at %s%n%n", startTime.toString());
new SimulationManager() new SimulationManager()
.withParameters(0.6, 3.7, 4.84, 14000d, 4000) .withParameters(0.6, 3.7, 4.84, 18000d, 4000)
.withOutputFile("D:\\Work\\Numass\\trapping\\trap 14, pinch 100A.out") .withOutputFile("D:\\Work\\Numass\\trapping\\test1.out")
// .withFieldMap(z, b) // .withFieldMap(z, b)
// .withDensity(5e20) .withDensity(1e19)
.simulateAll((int) 1e6); .simulateAll((int) 1e6);
Instant finishTime = Instant.now(); Instant finishTime = Instant.now();
System.out.printf("%nFinished at %s%n", finishTime.toString()); System.out.printf("%nFinished at %s%n", finishTime.toString());

View File

@ -11,6 +11,7 @@
*/ */
//#include "scatter.h" //#include "scatter.h"
#define _USE_MATH_DEFINES // for C
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>