szaghi / FiNeR

Fortran INI ParseR and generator
37 stars 5 forks source link

Support of complex numbers #14

Open kostyfisik opened 4 years ago

kostyfisik commented 4 years ago

In physics for numerical simulations we often use complex valued parameters, e.g. dielectric permittivity, impedance, frequency, etc., so it would be natural to support them. At the moment it can be done via array input, however, it is not very convenient...

szaghi commented 4 years ago

@kostyfisik

Hi, give me more details, how do you like to have formatted the input?

An example is really helpful.

kostyfisik commented 4 years ago

E.g. at the moment I use the following config:

[cylinder]
radius = 100.
; material
eps_real = 80.
eps_imag = 0.0001
; aspect ratio sweep settings
rl_min = 0.45
rl_max = 0.75
rl_steps = 15

complex number are nonstandard for INI files, so we can use Fortran standard notation, e.g. it would be nice jus to set it as:

[cylinder]
radius = 100.
; material
epsilon  = (80., 1.0d-4) ; water permittivity
; aspect ratio sweep settings
rl_min = 0.45
rl_max = 0.75
rl_steps = 15
szaghi commented 4 years ago

Currently you can pass the real/imag values as a simple "tuple", e.g.

[cylinder]
radius = 100.
; material
epsilon  = 80. 1.0d-4 

(I do not remember if inline comments are allowed sorry)

Anyhow, if you want to have the notation with ( , ) I can write a dedicated parser for it.

kostyfisik commented 4 years ago

It would be great. The final aim is just to

      call fini%get(section_name='cylinder', option_name='epsilon',
     &  val=epsilon, error=error)

to get complex(dp) :: epsilon type of variable.

I would say that

epsilon  = 80. 1.0d-4 

can be a bit cryptic for end users, who are far from programming (but still need to use fortran code to run simulations)

szaghi commented 4 years ago

Ok, let me few time (hours/days), I am working on other libraries, but I am close to update also FiNeR

kostyfisik commented 4 years ago

@szaghi Thank you a lot for a really useful project! If you are interested you can check how FiNeR and FLAP are used in the wild https://github.com/wave-scattering/amos-try/blob/master/cylinder2mod/axspartclnew4.f#L1855-L1974