-
Notifications
You must be signed in to change notification settings - Fork 5
Example Simulation Beginning to End
The main function of WavePy is to perform phase-screen based open-source split-step propagation wave optics simulations(WOS). In keeping with that theme, the following details how to run some basic propagation simulations with WavePy.
Instantiation The first step is to import wavepy as a standard python package, in this instance I import it along with some other useful libraries like so:
import wavepy as wavepy
import matplotlib as plt
import numpy as npThe Numpy is necessary for handling the outputs of WavePy and matplotlib is a useful tool for visualizing the intermediary and end results of your propagation simulation. The next step is to instantiate a WavePy object with your desired characteristics like so:
test = wavepy.wavepy()Wavepy has a set of default attributes when instantiated with no parameters. The parameters are are as follows: simOption for changing source model(types covered in Source generation wiki page), N is the resolution of the simulation, usually chosen to be powers of two, SideLen which is the length of one side of a square phase screen in meters, NumScr is the number of phase screens generated along the propagation length during simulation, DRx is the diameter of the aperture, dx is the sampling interval at the source plane, wvl is the wavelength of the source in meters, PropDist is the length of the propagation path in meters, Cn2 is the average turbulence strength parameter and is used to calculate the appropriate rytov number for the system, loon is a binary value of either zero or one to exclude or include sub-harmonic compensation respectively, aniso is the anisotropy magnitude, and Rdx is the sampling interval at the reciever plane. These can be defined during instantiation like this:
test = wavepy.wavepy(SideLen=20.0, PropDist=45.0)Several other values such as the turbulence inner and outer scale(l0,L0), the angle of isotropy(theta), the power law exponent(alpha), the number of sub harmonics included(NumSubHarmonics), and the transmitting aperture size for gaussian sources(DTx) can be changed, albeit in a slightly different way:
test = wavepy.wavepy()
test.l0 = 1e-2
test.NumSubHarmonics = 4Calculating Rytov Number and Running simulation After instantiating WavePy with the characteristics you want, it will calculate a default rytov number based off of the Cn2 value you've given, but if you would like to give your own rytov number(say 0.2 for this example) and set the Cn2 value off of that, the necessary step is as follows:
test.SetCn2Rytov(0.2)The next step is to run the propagation simulation and that is as follows:
test.TurbSim()Once the simulation is complete the Output parameter of WavePy will contain the results from propagation in array form. This is easily visualized by using the following matplotlib scheme:
plt.imshow(np.abs(test.Output)**2)The output is complex so taking the absolute value and squaring it is required to demonstrate its value in a pleasing image like this one:
