/** * Loads state from given strings array, treating first line as a general parameters and all other * as an array of particles' coordinates inside correspondent boxes. * * <p>throws Exception if no valid config could be read (either */ private void readCoordinates(List<String> strings) throws Exception { // first line format: // current step, boxBorder, avg. energy 1 (per prtcl), avg density 1, avg. energy 2, avg. // density 2, total Gamma String firstline = strings.remove(0); myEnsemble.setCurrStep(Integer.parseInt(firstline.split("\\s+")[0])); final int boxBorder = Integer.parseInt(firstline.split("\\s+")[1]); myEnsemble.setBoxBorder(boxBorder); final double avgE1 = Double.parseDouble(firstline.split("\\s+")[2]); final double density1 = Double.parseDouble(firstline.split("\\s+")[3]); final double avgE2 = Double.parseDouble(firstline.split("\\s+")[4]); final double density2 = Double.parseDouble(firstline.split("\\s+")[5]); myEnsemble.setCurrReducedEnergies(avgE1, avgE2); myEnsemble.setDensitiesAvg(density1, density2); if (strings.size() != Nei * 2) { throw new IndexOutOfBoundsException("file size doesn't fit particles number"); } for (int type = 0; type < 2; type++) { for (int i = 0 + type * Nei; i < Nei + type * Nei; i++) { String[] strs = strings.get(i).split("\\s"); prtcls[type][0][i - type * Nei] = Double.parseDouble(strs[0]); prtcls[type][1][i - type * Nei] = Double.parseDouble(strs[1]); prtcls[type][2][i - type * Nei] = Double.parseDouble(strs[2]); } } }