Set the parameters in the calculation.
()
| 148 | * Set the parameters in the calculation. |
| 149 | */ |
| 150 | @Override |
| 151 | public void initializeAnimation() { |
| 152 | stopAnimation(); |
| 153 | int newSize = control.getInt("grid size"); |
| 154 | if(newSize!=size) { |
| 155 | size = newSize; |
| 156 | spinData = new int[size][size]; |
| 157 | lattice = new BinaryLattice(size, size); |
| 158 | drawingPanel.clear(); |
| 159 | drawingPanel.addDrawable(lattice); |
| 160 | randomizeCells(); |
| 161 | } |
| 162 | flipsPerStep = size*size; |
| 163 | if(T<0) { |
| 164 | System.out.println("\nTemperature is negative, automatically negated!"); |
| 165 | T *= -1; |
| 166 | } |
| 167 | T = control.getDouble("T"); |
| 168 | H = control.getDouble("H"); |
| 169 | time_counter = 0; |
| 170 | getME(); |
| 171 | enData.clear(); |
| 172 | magData.clear(); |
| 173 | enData.append(time_counter/10.0, E); |
| 174 | magData.append(time_counter/10.0, M); |
| 175 | double ave = org.opensourcephysics.numerics.Util.computeAverage(magData.getYPoints(), 0, magData.getIndex()); |
| 176 | magPanel.setTitle("<M> = "+format.format((float) ave)); |
| 177 | ave = org.opensourcephysics.numerics.Util.computeAverage(enData.getYPoints(), 0, enData.getIndex()); |
| 178 | enPanel.setTitle("<E> = "+format.format((float) ave)); |
| 179 | enPanel.repaint(); |
| 180 | magPanel.repaint(); |
| 181 | drawingPanel.invalidateImage(); |
| 182 | drawingPanel.repaint(); |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Calculate the total energy and magnetization by summing over all spin states. |
no test coverage detected