### Solving the lens equation

Here is an example of how to generate and plot the grid. (This example uses an SIE lens.)

# SIE galaxy

# combine cartesian and polar grids

maingrid 1 -2.5 2.5 25 -2.5 2.5 25
galgrid 1 0.0 2.5 25 0 360 25

setlens 1 1
alpha 1 0 0 0.3 30 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0

set plotmode = 2
plotgrid grid1a.dat
plotcrit crit1a.dat

# now use logarithmic polar grid

maingrid 1 -2.5 2.5 25 -2.5 2.5 25
galgrid 1 1.0e-6 2.5 -25 0 360 25

setlens 1 1
alpha 1 0 0 0.3 30 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0

set plotmode = 2
plotgrid grid1b.dat
plotcrit crit1b.dat

quit

Here are the resulting grids, plotted with gnuplot. (Click on an image for the gnuplot commands.)

Image plane:

Source plane:

Here are two examples of how to solve the lens equation, using simple models that we can check analytically.

First, a point mass.

# point mass

# combine cartesian and polar grids
# polar grid must have a hole in the middle because ptmass diverges at origin

maingrid 1 -2.5 2.5 25 -2.5 2.5 25
galgrid 1 1.0e-6 2.5 25 0 360 25

setlens 1 1
ptmass 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

findimg 0.5 0.0

quit

Next, an isothermal sphere (nearly, but not quite, singular).

# SIS

# combine cartesian and polar grids

maingrid 1 -2.5 2.5 25 -2.5 2.5 25
galgrid 1 0.0 2.5 25 0 360 25

setlens 1 1
alpha 1 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0

findimg 0.5 0.0

quit