MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / initializeAnimation

Method initializeAnimation

src/debugging/physicsapps/IsingApp.java:150–183  ·  view source on GitHub ↗

Set the parameters in the calculation.

()

Source from the content-addressed store, hash-verified

148 * Set the parameters in the calculation.
149 */
150 @Override
151public 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.

Callers 1

initMyControlMethod · 0.95

Calls 15

randomizeCellsMethod · 0.95
getMEMethod · 0.95
computeAverageMethod · 0.80
stopAnimationMethod · 0.65
getIntMethod · 0.65
clearMethod · 0.65
printlnMethod · 0.65
getDoubleMethod · 0.65
appendMethod · 0.65
setTitleMethod · 0.65
repaintMethod · 0.65
addDrawableMethod · 0.45

Tested by

no test coverage detected