Make fortran calculation functions accept spherical coordinates as input

Registered by Vinothan N. Manoharan

Fortran functions in mieangfuncs.f90 such as mie_fields, tmatrix_fields, and single_holo currently accept cartesian coordinates of the detector pixels (kxgrid kygrid) as input. I propose changing them to accept arrays of spherical coordinates (kr, theta, phi) instead.

Rationale:
1) This would eliminate the constraint that the hologram be calculated on a flat plane, thus making it possible to do aberration correction and other optical train modeling.

2) This would also make it possible to use the code under the `model` module to do arbitrary scattering calculations, not just holograms. For example, it could be used to make intensity versus theta plots to compare to static light scattering.

3) This will improve the efficiency of fitting because the coordinates would be cached rather than computed at each iteration. It probably won't be a huge gain, but it wouldn't hurt.

I would suggest that we have the functions accept three arrays, [kr], [theta], [phi]. The dimensions of [theta] and [phi] are arbitrary, and need not be equal to one another. Call them N_theta and N_phi. [kr] should then have dimensions N_phi x N_theta. The field functions would return cartesian components of the fields on a grid of N_phi x N_theta. It would be up to the calling code to handle any conversions from cartesian to spherical coordinates (Jerome, please make sure this makes sense).

TGD responds: theta and phi actually need to be full NxM arrays, because their values both depend on x and y. I was able to get things working with passing in NxM arrays of kr, theta and phi (actually I just did an NxMx3 with all of them).

[JF responds: This is possible, and as I think about it I think it makes sense.

I agree with your first two points, but not your third. Spherical coordinates must always be specified relative to something; for scattering the center of the particle. But as the fitter moves the particle around relative to the lab frame (where the lab frame particle position is what we're physically after) the spherical coordinates change. You could use unchanging spherical coordinates relative to the origin of the hologram (upper left pixel has (r = z_particle, theta = phi = 0.) but converting to spherical coordinates relative to the particle is a mess.

The scheme I see working is the following: mie_fortran.forward_holo would keep track of the particle positions relative to the lab frame, and takes care of the computation of spherical coordinates relative to the particle(s). It would then call single_holo or mie_fields (the latter, once per particle) passing ([kr], [theta], [phi]) for each particle. One advantage I see here is encapsulation: the Fortran code then no longer cares about the particle coordinates relative to the lab frame. This is what you have in mind, yes?]

VNM: right - I was getting confused between lab frame and particle frame. But it certainly makes sense that the Fortran code should not care at all about the particle coordinates. It only needs r, theta, phi. Can you implement the changes to the Fortran code in dev? Stable should keep the old interface.

Blueprint information

Status:
Complete
Approver:
Jerome Fung
Priority:
High
Drafter:
Vinothan N. Manoharan
Direction:
Approved
Assignee:
Tom Dimiduk
Definition:
Approved
Series goal:
Accepted for dev
Implementation:
Implemented
Milestone target:
milestone icon 2.0
Started by
Jerome Fung
Completed by
Tom Dimiduk

Related branches

Sprints

Whiteboard

Working for mie scattering calculations in r57

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.