Example #1
0
def save_simulations(domain, data_directory, methods, target_errors):
    """ Save simulation data for each method to file. """
    for method in methods:
        print("%s" % method)

        for target_error in target_errors:
            print("\t%.1e" % target_error)

            method_error = "-".join([method, "%.0e" % (target_error)])
            filename = os.path.join(data_directory, method_error)

            system = System(domain)
            system.add(
                Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625))
            system.add(
                Sech(peak_power=8.8e-3,
                     width=(1.0 / 0.44),
                     position=0.375,
                     offset_nu=-0.8))
            system.add(
                Fibre("fibre",
                      length=400.0,
                      beta=[0.0, 0.0, -0.1, 0.0],
                      gamma=2.2,
                      method=method,
                      local_error=target_error))
            system.run()

            A_calc = system.fields['fibre']
            storage = system["fibre"].stepper.storage

            np.savez(filename, field=A_calc, ffts=storage.fft_total)
Example #2
0
def generate_overview_plots(domain):
    """ Generate single, map, and waterfall plots of the soliton collision. """
    system = System(domain)
    system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44),
                    position=0.625))
    system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44),
                    position=0.375, offset_nu=-0.8))
    system.add(Fibre(length=400.0, beta=[0.0, 0.0, -0.1, 0.0],
                     gamma=2.2, total_steps=400, traces=100,
                     method='ARK4IP', local_error=1e-6))
    system.run()

    storage = system['fibre'].stepper.storage
    (x, y, z) = storage.get_plot_data(reduced_range=(140.0, 360.0))

    # Split step_sizes (list of tuples) into separate lists;
    # distances and steps:
    (distances, steps) = list(zip(*storage.step_sizes))

    print(np.sum(steps))

    single_plot(distances, steps, labels["z"], "Step size, h (km)",
                filename="soliton_collision_steps")

    map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"],
             filename="soliton_collision_map")

    waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"],
                   filename="soliton_collision_waterfall",
                   y_range=(0.0, 0.02))
Example #3
0
def generate_reference(domain, data_directory):
    """ Generate a reference field (to machine precision), used as A_true. """
    system = System(domain)
    system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44),
                    position=0.125))
    system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44),
                    position=-0.125, offset_nu=-0.8))
    system.add(Fibre("fibre", length=400.0, beta=[0.0, 0.0, -0.1, 0.0],
                     gamma=2.2, method="ark4ip", local_error=1e-14))
    system.run()

    A_true = system.field

    filename = os.path.join(data_directory, "reference_field")
    np.save(filename, A_true)
Example #4
0
def save_simulations(domain, data_directory, methods, target_errors):
    """ Save data for each method and target error to file. """
    for method in methods:
        print("%s" % method)

        for target_error in target_errors:
            print("\t%.1e" % target_error)

            method_error = "-".join([method, "%.0e" % (target_error)])
            filename = os.path.join(data_directory, method_error)

            system = System(domain)
            system.add(Sech(peak_power=4.0, width=1.0))
            system.add(
                Fibre("fibre",
                      length=0.5 * np.pi,
                      beta=[0.0, 0.0, -1.0, 0.0],
                      gamma=1.0,
                      method=method,
                      local_error=target_error))
            system.run()

            A_calc = system.fields['fibre']
            storage = system["fibre"].stepper.storage

            np.savez(filename, field=A_calc, ffts=storage.fft_total)
Example #5
0
def generate_map_and_waterfall_plots(domain):
    """ Generate map and waterfall plots to visualise pulse propagation. """
    system = System(domain)
    system.add(Sech(peak_power=4.0, width=1.0))
    system.add(
        Fibre("fibre",
              length=0.5 * np.pi,
              beta=[0.0, 0.0, -1.0, 0.0],
              gamma=1.0,
              method="rk4ip",
              total_steps=1000,
              traces=50))
    system.run()

    storage = system['fibre'].stepper.storage
    (x, y, z) = storage.get_plot_data(reduced_range=(95.0, 105.0))

    map_plot(x,
             y,
             z,
             labels["t"],
             labels["P_t"],
             labels["z"],
             filename="soliton_map")

    waterfall_plot(x,
                   y,
                   z,
                   labels["t"],
                   labels["z"],
                   labels["P_t"],
                   filename="soliton_waterfall",
                   y_range=(0.0, 16.0))
Example #6
0
def save_simulations(domain, data_directory, methods, steps):
    """ Save data for each method and step to file. """
    for method in methods:
        print "%s" % method

        for step in steps:
            print "\t%d" % step

            method_step = "-".join([method, str(step)])
            filename = os.path.join(data_directory, method_step)

            system = System(domain)
            system.add(Sech(peak_power=4.0, width=1.0))
            system.add(
                Fibre("fibre",
                      length=0.5 * np.pi,
                      beta=[0.0, 0.0, -1.0, 0.0],
                      gamma=1.0,
                      method=method,
                      total_steps=step))
            system.run()

            A_calc = system.fields['fibre']
            np.save(filename, A_calc)
Example #7
0
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
from pyofss import Domain, System, Sech, Fibre
from pyofss import map_plot, waterfall_plot, animated_plot, labels

system = System(Domain(bit_width=100.0, samples_per_bit=2048))

absolute_separation = 3.5
offset = absolute_separation / system.domain.bit_width

system.add(Sech(peak_power=1.0, width=1.0, position=0.5 - offset))
system.add(Sech(peak_power=1.1, width=1.0, position=0.5 + offset))

system.add(
    Fibre(length=90.0,
          beta=[0.0, 0.0, -1.0, 0.0],
          gamma=1.0,
          total_steps=200,
          traces=100,
          method='ARK4IP'))
system.run()

storage = system['fibre'].stepper.storage
(x, y, z) = storage.get_plot_data(reduced_range=(40.0, 60.0))

map_plot(x,
Example #8
0
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
from pyofss import Domain, System, Sech, Fibre
from pyofss import map_plot, waterfall_plot, animated_plot, labels

system = System(Domain(bit_width=100.0, samples_per_bit=4096))
system.add(Sech(peak_power=1.0, width=1.0))
system.add(
    Fibre(length=4.0,
          beta=[0.0, 0.0, 0.0, 1.0],
          gamma=4.0,
          traces=100,
          method='ARK4IP'))
system.run()

storage = system['fibre'].stepper.storage
(x, y, z) = storage.get_plot_data(False, (192.1, 194.1), normalised=True)

map_plot(x,
         y,
         z,
         labels["nu"],
Example #9
0
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
from pyofss import Domain, System, Sech, Fibre
from pyofss import map_plot, waterfall_plot, animated_plot, labels

system = System(Domain(bit_width=100.0, samples_per_bit=2048))

absolute_separation = 3.5
offset = absolute_separation / system.domain.bit_width

system.add(Sech(peak_power=1.0, width=1.0, position=-offset))
system.add(Sech(peak_power=1.0, width=1.0, position=+offset))

system.add(
    Fibre(length=90.0,
          beta=[0.0, 0.0, -1.0, 0.0],
          gamma=1.0,
          total_steps=200,
          traces=200,
          method='ARK4IP'))
system.run()

storage = system['fibre'].stepper.storage
(x, y, z) = storage.get_plot_data(reduced_range=(-10.0, 10.0))

map_plot(x,
Example #10
0
beta_2 = convert_dispersion_to_physical(D)[0]

delta_3 = 0.03
beta_3 = 6.0 * np.abs(beta_2) * width * delta_3

beta = [0.0, 0.0, beta_2, beta_3]

L_D = (width**2) / np.abs(beta_2)
length = 4.0 * L_D

N = 2.0
P_0 = 1.0
gamma = (N**2) / (L_D * P_0)

system = System(domain)
system.add(Sech(peak_power=P_0, width=width))
system.add(
    Fibre(length=length,
          gamma=gamma,
          beta=beta,
          rs_factor=T_R,
          raman_scattering=True,
          self_steepening=True,
          total_steps=200,
          traces=100,
          method='ARK4IP'))
system.run()

storage = system['fibre'].stepper.storage
(x, y, z_temp) = storage.get_plot_data(False, (71.9, 314.9), True)
z_label = r"Fibre length, $z \, (cm)$"
Example #11
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
import numpy as np
from pyofss import Domain, System, Sech, Fibre
from pyofss import map_plot, waterfall_plot, animated_plot, labels

system = System(Domain(bit_width=100.0, samples_per_bit=2048))

absolute_separation = 3.5
offset = absolute_separation / system.domain.bit_width

system.add(Sech(peak_power=1.0, width=1.0, position=0.5 - offset))
system.add(
    Sech(peak_power=1.0,
         width=1.0,
         position=0.5 + offset,
         initial_phase=np.pi / 4.0))

system.add(
    Fibre(length=90.0,
          beta=[0.0, 0.0, -1.0, 0.0],
          gamma=1.0,
          total_steps=200,
          traces=100,
          method='ARK4IP'))
system.run()
Example #12
0
    def __str__(self):
        """
        :return: Information string
        :rtype: string

        Output information on Sech.
        """

        output_string = [
            'position = {0:f}', 'width = {1:f} ps', 'fwhm = {2:f} ps',
            'peak_power = {3:f} W', 'offset_nu = {4:f} THz',
            'C = {5:f}', 'initial_phase = {6:f} rad', 'channel = {7:d}']

        return "\n".join(output_string).format(
            self.position, self.width, self.calculate_fwhm(), self.peak_power,
            self.offset_nu, self.C, self.initial_phase, self.channel)

if __name__ == "__main__":
    """ Plot a default Sech in temporal and spectral domain """
    from pyofss import Domain, System, Sech
    from pyofss import temporal_power, spectral_power
    from pyofss import double_plot, labels

    sys = System(Domain(bit_width=500.0))
    sys.add(Sech())
    sys.run()

    double_plot(sys.domain.t, temporal_power(sys.field),
                sys.domain.nu, spectral_power(sys.field, True),
                labels["t"], labels["P_t"], labels["nu"], labels["P_nu"])
Example #13
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys
import numpy as np
from pyofss import Domain, System, Sech, Fibre
from pyofss import map_plot, waterfall_plot, animated_plot, labels

system = System(Domain(bit_width=100.0, samples_per_bit=2048))

absolute_separation = 3.5
offset = absolute_separation / system.domain.bit_width

system.add(Sech(peak_power=1.0, width=1.0, position=-offset))
system.add(Sech(peak_power=1.0, width=1.0, position=+offset,
                initial_phase=np.pi / 2.0))

system.add(Fibre(length=90.0, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0,
                 total_steps=200, traces=100, method='ARK4IP'))
system.run()

storage = system['fibre'].stepper.storage
(x, y, z) = storage.get_plot_data(reduced_range=(-10.0, 10.0))

map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"],
         filename="5-16c_map")

waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"],
               filename="5-16c_waterfall", y_range=(0.0, 1.2))