PieterTack / polycap

Polycapillary X-ray raytracing
GNU General Public License v3.0
3 stars 3 forks source link

Allow straightforward user-supplied optic shapes #41

Open PieterTack opened 5 years ago

PieterTack commented 5 years ago

We should probably add a function to allow the user to define a custom shape by providing the radial coordinates directly as arrays instead of using files.

In a way this is already possible: this array is what is stored in the polycap_source structure (which contains a polycap_description structure, which in turn contains a polycap_profile structure that is in fact nothing else but the radial coordinates array that you mention)

It may be easier to make a function that easily (re)allocs this source->description->profile, when supplied with appropriate arrays. Or do we just leave it as is, where the user can first go through polycap_profile_new(), polycap_description_new() and then polycap_source_new(), after which the actual calculation program can be called?

tschoonj commented 5 years ago

Hey Pieter,

I assume you're referring to the polycap_profile member variables?

https://github.com/PieterTack/polycap/blob/bcf6b406a05af7d12f4ebc954082d6f2d28415fa/src/polycap-private.h#L79-L85

If you would like the user to define these directly, I would recommend writing a function like:

polycap_profile* polycap_profile_custom_new(int nmax, double *z, double *cap, double *ext);

The returned struct can subsequently be used to produce a polycap_description and polycap_source.

Actually I have been thinking: perhaps the current polycap_profile_new can be rewritten as three functions specific to the different types you support: polycap_profile_conical_new, polycap_profile_paraboloidal_new and polycap_profile_ellipsoidal_new. This would be cleaner since the current 7 double arguments are not actually used by all three types if I am not mistaken...