-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python interface for Gaussian beam source #1310
Conversation
Getting closer: the problem now is creating a C++ Currently, the line involving elif isinstance (src, GaussianBeamSource):
gaussianbeam_args = [
py_v3_to_vec(self.dimensions, src.beam_x0, is_cylindrical=self.is_cylindrical),
py_v3_to_vec(self.dimensions, src.beam_kdir, is_cylindrical=self.is_cylindrical),
src.beam_w0,
src.src.swigobj.frequency().real,
self.fields.get_eps(py_v3_to_vec(self.dimensions, src.center, self.is_cylindrical)).real,
self.fields.get_mu(py_v3_to_vec(self.dimensions, src.center, self.is_cylindrical)).real,
[src.beam_E0.x, src.beam_E0.y, src.beam_E0.z]
]
gaussianbeam = functools.partial(mp.gaussianbeam, *gaussianbeam_args)
add_vol_src_args = [src.src.swigobj, where, gaussianbeam()]
From the error message, the problem is the last argument gaussianbeam(const vec &x0, const vec &kdir, double w0, double freq,
double eps, double mu, std::complex<double> EO[3]); Python is unable to convert the list of three complex values ( Any thoughts? |
Renaming the
I also tried passing Perhaps the SWIG typemap for |
How is the beam waist defined here? i.e. is there a 2 in the gaussian exponential? Would be nice to grab a cross-section of the fields, and plot an analytical gaussian with the same beam waist on top. |
For definitions of all the parameters as well as the formula for the beam itself, see the wikipedia article. There is also a helpful figure that shows the beam waist |
Documentation, tutorial example (part of the revised FAQ), and test (Python) have been added. Unfortunately, because the The test verifies that the energy at the beam focus (for an oblique source) is more than 99% of the maximum energy over the entire cell. Here are some additional demonstrations included in the tutorial example. |
* Python interface for Gaussian beam source * create gaussianbeam object in Python using functools.partial * rename gaussianbeam constructor argument EO to E0 * pass E0 from Python as NumPy array * add documentation, tutorial example, and test (Python) * Update Python_User_Interface.md * Update Python_User_Interface.md Co-authored-by: Steven G. Johnson <[email protected]>
Initial attempt at a Python interface for the Gaussian beam source based on adding a new class
GaussianBeamSource
as described in #701:comment. Documentation, test, and tutorial will eventually be added to this PR once the API is working properly.It compiles but a simple test in 2d aborts with the error:
The error is occuring during the call to the
GaussianBeamSource
constructor. It's unclear what is causing this error since thebeam_x0
parameter is just aVector3
object.