← Back to team overview

python-meep team mailing list archive

Re: python-meep harminv

 

> Here in our group there is a need for better harminv support. We now
> have some helper functions in the python-meep bindings, but we propose
> to make it more user friendly for users and to make a function :
> 
> runWithHarminv(component, harminv_time, probing_point, fcen, df)
> 
> ...that runs the sources until they are finished, and then performs a
> harminv analysis during "harminv_time" timesteps at the probing point
> around frequency fcen with bandwith df.
> 
> We propose to make a class HarminvResult with 6 members :
> frequency, imag. freq., Q, |amp|, amplitude, error
> 
> The result of "runWithHarminv" should be a list of HarminvResult
> objects.
> 
> Please send your comments about this proposal.

Well, I never used harminv, just implemented it in tests. From the code I see that current 
realization is just quick and dirty implementation in c style, using c arrays, pre-allocations of 
returned arrays, etc - not as clean as pythonic. If you can do it better, so that tests - 
2d_convergence and convergence_cyl_waveguide look less cryptic - why not ?

But, it should be either a function with argument of fields() class like 
runWithHarminv(fields, component, harminv_time, probing_point, fcen, df)
or a method of fields() class like: 
fields.runWithHarminv(component, harminv_time, probing_point, fcen, df)
and, maybe, both. 
 
Here appears the usability problem - Scheme interface supports the 'attaching' of some actions to 
time-stepping. Like - every 20 steps output the field, or make a harminv call after some condition 
have been met at some point in the space, etc. If I recoll correctly, it also allows to do it for 
several fields() instances implicitly. This is a powerful feature of Scheme and we have to think 
about how to implement it in Python.  
Smth. like 

set_simulation(list fields instances)			 	# save to the single global class ?
set_every(20, action)						# every 20 time steps make some action 
at_beginning(action)						# at beginning of the simulation or at the end make some action 
set_mon_point(vec)							# set monitor points 
set_mon_point(vec, action)					# set monitor points with action  - e.g. collect the fields to array
at_the_end(action)							# for example, run harminv, or output the fields
run()

This is just a vision of the how such functionality will be implemented in the future, right now it 
is not clear how to describe actions in python way.  We already have runUntilDecayed and you will 
implement similar in spirit function. But at the end, we have to match Scheme's usability. Probably, 
Python's anonymous functions (aka lambda) will do the trick, I am not sure.   

wbr,
Shawkat



References