import com.comsol.model.*; import com.comsol.model.util.*; import java.util.Arrays; import java.io.*; public class export_elecStat { public static void main(String[] args) { System.out.println("Starting"); run(args[0],args[1]); System.out.println("Done"); return; } public static int run(String outpath, String fieldf) { Model model; model = ModelUtil.model(System.getProperty("cs.currentmodel")); //String outpath="/home/mberger/fopiroot/fopiroot_dev/padresponse_COMSOL/"; //String fieldf="elecDrift.txt"; File outfile=new File(outpath+fieldf); FileWriter writer; try { writer=new FileWriter(outfile,false); /* writer.write("# px=Particle position X\n"); writer.write("# py=Particle position Y\n"); writer.write("# pz=Particle position Y\n"); writer.write("# wEx=Weighting field component X\n"); writer.write("# wEy=Weighting field component Y\n"); writer.write("# wEz=Weighting field component Z\n"); writer.write("# vx=Particle velocity X\n"); writer.write("# vy=Particle velocity Y\n"); writer.write("# vz=Particle velocity Z\n"); writer.write("# px py pz wEx wEy wEz vx vy vz\n"); */ model.result().numerical("par1").set("timeinterp", "on"); model.result().numerical("par2").set("timeinterp", "on"); double[][] particleRelT; double[][] particleStopT; particleRelT=model.result().numerical("par6").getReal(); particleStopT=model.result().numerical("par7").getReal(); //System.out.println(Arrays.toString(model.sol("sol3").getPVals())); double timestep=model.sol("sol3").getPVals()[1]-model.sol("sol3").getPVals()[0]; //count times int ipart,ipos; double oldtime=particleRelT[0][0]; int numRelTimes=1; for(ipart=0;ipart0) particleRelT[ipart][0]+=timestep; if(oldtime!=particleRelT[ipart][0]) { numRelTimes++; oldtime=particleRelT[ipart][0]; } } //fill array with the release times double[] reltimes=new double[numRelTimes]; double maxStopTime=0; reltimes[0]=particleRelT[0][0]; int counter=0; for(ipart=0;ipart