Minor accessibility fixes

This commit is contained in:
Alexander Nozik 2017-01-11 14:49:10 +03:00
parent 3c0eec6591
commit ca59a325f3
3 changed files with 54 additions and 30 deletions

View File

@ -1,5 +1,5 @@
apply plugin: 'java'
apply plugin: 'c'
//apply plugin: 'c'
apply plugin: 'idea'
apply plugin: 'application'
@ -42,20 +42,20 @@ task runTrap(type: JavaExec) {
// native component
model {
components {
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"
}
}
}
//model {
// components {
// 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"
// }
//
// }
//}

View File

@ -20,14 +20,34 @@ public class SimulationManager {
RandomGenerator generator = new JDKRandomGenerator();
Simulator simulator = new Simulator();
private double initialE = 18000;
private double range = 4000;
private PrintStream output = System.out;
private PrintStream statisticOutput = System.out;
private Predicate<Simulator.SimulationResult> reportFileter = (res) -> res.state == Simulator.EndState.ACCEPTED;
// public SimulationManager withParameters(double bSource, double bTransport, double bPinch, double initialE, double energyRange) {
// this.simulator = new Simulator(bSource, bTransport, bPinch, initialE - energyRange);
// this.initialE = initialE;
// return this;
// }
public SimulationManager withParameters(double bSource, double bTransport, double bPinch, double initialE, double energyRange) {
this.simulator = new Simulator(bSource, bTransport, bPinch, initialE - energyRange);
public SimulationManager withInitialE(double initialE){
this.initialE = initialE;
simulator.setELow(initialE-range);
return this;
}
public SimulationManager withRange(double range){
this.range = range;
simulator.setELow(initialE-range);
return this;
}
public SimulationManager withFields(double bSource, double bTransport, double bPinch){
this.simulator.setFields(bSource,bTransport,bPinch);
return this;
}
@ -63,6 +83,11 @@ public class SimulationManager {
return this;
}
public SimulationManager withReportFilter(Predicate<Simulator.SimulationResult> filter) {
this.reportFileter = filter;
return this;
}
/**
* Set field map as function
*
@ -93,7 +118,7 @@ public class SimulationManager {
* @param density
* @return
*/
public SimulationManager withDensity(double density) {
public SimulationManager withGasDensity(double density) {
this.simulator.setGasDensity(density);
return this;
}
@ -106,14 +131,13 @@ public class SimulationManager {
*/
public synchronized Counter simulateAll(int num) {
Counter counter = new Counter();
Predicate<Simulator.SimulationResult> reportIf = (res) -> res.state == Simulator.EndState.ACCEPTED;
System.out.printf("%nStarting sumulation with initial energy %g and %d electrons.%n%n", initialE, num);
output.printf("%s\t%s\t%s\t%s\t%s\t%s%n", "E", "theta", "theta_start", "colNum", "L", "state");
Stream.generate(() -> getRandomTheta()).limit(num).parallel()
.forEach((theta) -> {
double initZ = (generator.nextDouble() - 0.5) * Simulator.SOURCE_LENGTH;
Simulator.SimulationResult res = simulator.simulate(initialE, theta, initZ);
if (reportIf.test(res)) {
if (reportFileter.test(res)) {
if (output != null) {
printOne(output, res);
}

View File

@ -1,27 +1,27 @@
package inr.numass.trapping;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.util.function.Predicate;
public class Trapping {
public static void main(String[] args) throws IOException {
// new SimulationManager().withParameters(0.6, 3.7, 7.2, 18000d, 4000).simulateAll((int) 1e6);
double[] z = {-1.736, -1.27, -0.754, -0.238, 0.278, 0.794, 1.31, 1.776};
double[] b = {3.70754, 0.62786, 0.60474, 0.60325, 0.60333, 0.60503, 0.6285, 3.70478};
System.out.println("Press any key to start...");
System.in.read();
// System.out.println("Press any key to start...");
// System.in.read();
Instant startTime = Instant.now();
System.out.printf("Starting at %s%n%n", startTime.toString());
new SimulationManager()
.withParameters(0.6, 3.7, 4.84, 18000d, 4000)
.withOutputFile("D:\\Work\\Numass\\trapping\\test1.out")
.withFields(0.6, 3.7, 7.2)
// .withFieldMap(z, b)
.withDensity(1e19)
.withGasDensity(1e19) // per m^3
.withReportFilter(res -> true)
.simulateAll((int) 1e6);
Instant finishTime = Instant.now();
System.out.printf("%nFinished at %s%n", finishTime.toString());
System.out.printf("Calculation took %s%n", Duration.between(startTime,finishTime).toString());
System.out.printf("Calculation took %s%n", Duration.between(startTime, finishTime).toString());
}
}