Hmm... quick&dirty in Excel:

The idea: Use a cylindrical coordinate system with the obvious orientation. The system is invariant under phi-rotation, therefore it is sufficient to model the two-dimensional (rho,z)-plane.
Determine the potential phi at each point of this plane with some finite resolution. The sample and the electrode get a fixed phi of 0 and 1, respectively. For all other points, the Maxwell equations give
0 = \nabla^2 \phi = \frac{1}{\rho} \partial_\rho \left( \rho\; \partial_\rho \phi \right) + \partial^2_z \phi. The electric field is then given by the gradient of the potential.
To apply this to a grid, the derivatives have to be transformed to differences of grid cells i:
\partial f(i+1/2) = f(i+1) - f(i)This allows to calculate the second derivatives as
\partial^2 f(i) = \partial f(i+1/2)-\partial f(i-1/2) = f(i+1) + f(i-1) - 2f(i)
and
\frac{1}{i} \partial \left(i\; \partial f(i)\right) = \frac{1}{i} \left[ \left(i+\frac{1}{2}\right) \partial f(i+1/2) - \left(i-\frac{1}{2}\right) \partial f(i-1/2) \right] = \frac{1}{i} \left[ \left(i+\frac{1}{2}\right) \left(f(i+1) - f(i)\right) - \left(i-\frac{1}{2}\right) \left(f(i) - f(i-1)\right) \right]
Putting everything together, solving for a specific cell and using the index i for the rho-coordinate and j (columns) for z, I get
\phi(i,j)==\frac{1}{2}\left((\phi(i,j-1)+\phi(i,j+1))/2+\frac{1}{2i}\left((i+1/2)*\phi(i+1,j)+(i-1/2)\phi(i-1,j)\right)\right)
I hope that the prefactors are right.
As the simulated area is finite, there are 4 borders to consider:
- the sample border is simple, as it has a fixed potential.
- rho=0 is a coordinate singularity and cannot be calculated using the formula given above. But there, it is easy to get the appropriate formula from cartesian coordinates:
\phi(0,j)=\frac{1}{6}\left(\phi(0,j+1)+\phi(0,j-1)+4\phi(1,j)\right)
- far away from the sample. This needs a bit more thought. Here, I just assumed that the field is nearly constant with z, and therefore
\phi(i,0)=\phi(i,1). This is a good approximation for the region close to the electrode, but not so good far away from both sample and electrode.
- far away from the electrode. This is the most tricky case. Depending on the precision you need, it might be sufficient to just assume a nearly constant potential here or a constant first derivative in rho-direction or something similar.
The component of the electric field in one direction is then given by
E = \partial \phi(i) \approx \frac{1}{2} \left(\partial \phi(i+1/2) + \partial \phi(i-1/2)\right) = \frac{1}{2}\left(\phi(i+1)-\phi(i-1)\right)
Here is the magnitude of the E-field as
graph.
Every reasonable programming language which supports arrays can calculate this, and as all calculations are quite basic it should be easy to implement it.
There are certainly better ways to calculate the electric potential and field, and it might be useful to decrease the grid size close to the electrode (especially the corner of it, as it has the highest field strength). Smaller grid cells everywhere can do the same job, they just need more computing power.
Is that useful for you?