pyNLO / PyNLO

Python package for nonlinear optics
https://pynlo.readthedocs.io/en/latest/
GNU General Public License v3.0
96 stars 52 forks source link

input not plotted correctly #33

Closed hn-88 closed 8 years ago

hn-88 commented 8 years ago

Just to check @DanHickstein 's comment that 'steps' is only used in plotting, I tried changing the Steps=50 to Steps=3 in the example at http://pynlo.readthedocs.io/en/latest/example_simple.html

It worked fine. Only issue was that the input pulse was not graphed correctly (in blue, in the top two graphs). My first thought was that instead of zW[0], zW[1] is being graphed. But in the code, it is zW[0]

scg3

Not sure how important this is. Probably can be ignored?

DanHickstein commented 8 years ago

This is an important observation - I had actually assumed that the first element (well, first column I suppose, since it gets transposed on it's way to becoming the zW array in that example) in the ZW array was indeed the pulse before any propagation. In my simulations, very little changes during the first step, so I had never realized that it was different that the original pulse. You can always access the 1D array corresponding to the intensity of the original pulse using pulse.AW.

I think that the argument could be made that AW should not include the first step, since it only includes the results after propagation. Personally, I think that it would be more intuitive if it did include the field at y=0. As it stands, there is currently an inconsistency in that the returned z_positions array contains (n_steps + 1) elements, while the size of AW and AT is (pulse_in.NPTS, n_steps). (I'm looking around Line 511 of SSFM.py)

@ycasg, what do you think? Should we include the pulse before propagation as the first element of AW and AT returned by SSFM.propagate? Or, should be drop the first element of z_positions?

ycasg commented 8 years ago

I had been happy with the way this was working, as the pulse_in and pulse_out objects can access the field at the endpoints. However, I just pulled my copy of Numerical Recipes off the shelf and looked at the ODE integrator algorithm that they implement. Not only is this ia pretty good reference for numerical algorithms, but it is what I use in the pyNLO Dopri integrator.

In it, the output grid does in fact start at x1 and end at x2, with a total of N+1 points; the +1 is the initial value. I think that we should change the SSFM output grid to this standard.

DanHickstein commented 8 years ago

Sounds good, I think that is intuitively what @hn-88 and I expected would happen, so it must be the right thing to do :)

DanHickstein commented 8 years ago

Let's keep this issue open to remind us to make the change.