13 #include "definitions.h"
16 extern int width, height;
17 extern double **Vij, **Er;
18 extern unsigned char **oddity;
19 extern int dielectrics_to_consider_just_now;
23 #include "exit_codes.h"
25 double finite_difference_single_threaded()
28 int number_of_iterations=25;
29 double capacitance_per_metre, energy_per_metre;
31 /* The following might not look very neat, with a whole load of code being
32 written twice, when it would be posible to make it easier to read if the
33 'if(dielectrics_in_bitmap > 1)' was in an inner loop. However, the
34 following is almost certainly more efficient. It is not a good idea to
35 have any more than necessary in the inner loop.
37 The option to avoid the faster convergence algorithm has been didtched
38 too, as this was in an inner loop. The faster covergence method seems
39 to work fine, so there is no need to avoid using it */
42 /* Note, that while the number of intterations requested is set in the first
43 parameter to update_voltage_array, the actual number done is 4x higher, as
44 each computation id done in 4 directions */
46 update_voltage_array(number_of_iterations, 0, width-1, 0, height-1, Vij, Vij);
48 /* Once the voltage distribution is found, the energy in the field may be
49 found. This can be shown to be Energy = 0.5 * integral(E.D) dV, when
50 integrated over a volume V, and D.E is the vector dot product of E and
53 Energy per metre is 0.5 * D.E or (0.5*Epsilon)* E.E. Now E.E is given
54 by Ex^2 + Ey^2 (by definition of a dot product. */
60 energy_per_metre+=find_energy_per_metre(i,j);
63 capacitance_per_metre=2*energy_per_metre;
65 capacitance_per_metre=energy_per_metre;
66 return(capacitance_per_metre);
68 #endif /* #endif to #ifndef ENABLE_MP */