Skip to content

Commit

Permalink
update gh-action
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPdeS committed Dec 10, 2024
1 parent 04218e9 commit 5591e63
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 157 deletions.
56 changes: 14 additions & 42 deletions .github/workflows/deploy_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .github/workflows/coverage.yml
name: Coverage
# Simple workflow for deploying static content to GitHub Pages
name: Deploy coverage

on:
push:
Expand All @@ -9,45 +9,17 @@ on:
pull_request:
branches: [ "master" ]

jobs:
coverage:
name: Run test and generate coverage data
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write

steps:
- name: "Set-up: Python ${{ env.cp_python_version }}"
uses: actions/setup-python@v5
id: cp310
with:
python-version: "3.11"


- name: "Install: Dependencies for headless server"
shell: bash
run: |
sudo apt-get update
# sudo apt-get install libgl1-mesa-glx xvfb
sudo apt-get install xvfb
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write

- name: "Checkout requirements and files for testing"
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Install everything, run the tests, produce the .coverage file
run: |
python -m pip install wheel build
python -m build --wheel
python -m pip install .[testing]
pytest
- name: Coverage comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 50
jobs:
ManyLinux_x86_64:
uses: MartinPdeS/MPSActions/.github/workflows/publish_coverage.yml@master
with:
python-version: "3.11"
secrets:
_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions .github/workflows/deploy_documentation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

name: Deploy documentation to github page

on:
push:
Expand All @@ -20,3 +19,5 @@ permissions:
jobs:
ManyLinux_x86_64:
uses: MartinPdeS/MPSActions/.github/workflows/publish_documentation.yml@master
with:
python-version: "3.11"
10 changes: 9 additions & 1 deletion SuPyMode/representation/adiabatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy
from SuPyMode.representation.base import InheritFromSuperMode, BaseMultiModePlot
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker


class Adiabatic(InheritFromSuperMode, BaseMultiModePlot):
Expand Down Expand Up @@ -67,9 +68,16 @@ def _dress_ax(self, ax: plt.Axes) -> None:
The axis object on which to set the labels.
"""
ax.set(
yscale='log',
xlabel='Inverse taper ratio',
ylabel=r'Adiabatic criterion [$\mu$m$^{-1}$]',
ylim=[1e-5, 1],
ylim=[1e-5 * 1e6, 1 * 1e6],
)

def log_scale_yaxis(value, tick_position):
return f'{value / 1e6:.0e}'

# Apply the custom formatter for log scale
ax.yaxis.set_major_formatter(ticker.FuncFormatter(log_scale_yaxis))

# -
4 changes: 2 additions & 2 deletions SuPyMode/representation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def plot(self, ax: plt.Axes = None, show: bool = True) -> plt.Figure:
else:
figure = ax.figure

self._dress_ax(ax)

ax.plot(self.itr_list, self.data, label=f'{self.stylized_label}', linewidth=2)

ax.legend()

self._dress_ax(ax)

if show:
plt.show()

Expand Down
5 changes: 0 additions & 5 deletions SuPyMode/superset_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ def plot_adiabatic(
for profile in numpy.atleast_1d(add_profile):
profile.render_adiabatic_factor_vs_itr_on_ax(ax=ax, line_style='--')

ax.set(
yscale='log',
ylim=[1e-5, 1]
)

@parse_mode_of_interest
def plot_field(
self,
Expand Down
188 changes: 83 additions & 105 deletions developments/rodrigo_estupido_3.py
Original file line number Diff line number Diff line change
@@ -1,131 +1,109 @@
"""
3x3 Coupler
===========
"""

# %%
# Importing the script dependencies
from SuPyMode.workflow import Workflow, configuration, fiber_catalogue, Boundaries

# %%
# Creating the fiber list for mesh
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# In this example we want to simulate a single fiber at wavelength 1550 nm.
wavelength = 900e-9

# %%
# Generating the fiber structure
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Here we define the cladding and fiber structure to model the problem
clad_structure = configuration.ring.FusedProfile_03x03

custom_fiber_1 = fiber_catalogue.CustomFiber(wavelength=wavelength)
custom_fiber_1.add_silica_pure_cladding(radius=62.5e-6, name='outer-clad')

custom_fiber_1.create_and_add_new_structure(
radius=11.5e-6,
NA=0.2,
name='inner-clad'
)
from SuPyMode.workflow import Workflow, configuration, fiber_catalogue, Boundaries, AlphaProfile

custom_fiber_1.create_and_add_new_structure(
radius=2.0e-6,
NA=0.13,
name='core'
)
wavelength = 1550e-9


custom_fiber_2 = fiber_catalogue.CustomFiber(wavelength=wavelength)
custom_fiber_2.add_silica_pure_cladding(radius=62.5e-6, name='outer-clad')
fiber_0 = fiber_catalogue.GenericFiber(wavelength=wavelength)
fiber_0.add_silica_pure_cladding()
fiber_0.create_and_add_new_structure(name='core', radius=9.0e-6 / 2, NA=0.14)

custom_fiber_2.create_and_add_new_structure(
radius=13.1e-6,
NA=0.19,
name='inner-clad'
)
fiber_1 = fiber_catalogue.GenericFiber(wavelength=wavelength)
fiber_1.add_silica_pure_cladding()
fiber_1.create_and_add_new_structure(name='core', radius=11.0e-6 / 2, NA=0.14)

custom_fiber_2.create_and_add_new_structure(
radius=2.05e-6,
NA=0.117,
name='core'
)
fiber_2 = fiber_catalogue.GenericFiber(wavelength=wavelength)
fiber_2.add_silica_pure_cladding()
fiber_2.create_and_add_new_structure(name='core', radius=13.0e-6 / 2, NA=0.14)

fiber_configuration_0 = [
fiber_0, fiber_1, fiber_2
]


custom_fiber_3 = fiber_catalogue.CustomFiber(wavelength=wavelength)
custom_fiber_3.add_silica_pure_cladding(radius=62.5e-6, name='outer-clad')
# fiber_0 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_0.add_silica_pure_cladding()
# fiber_0.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19) # or 0.15
# fiber_0.create_and_add_new_structure(name='core', radius=9.0e-6 / 2, NA=0.14)

custom_fiber_3.create_and_add_new_structure(
radius=14.9e-6,
NA=0.2,
name='inner-clad'
)
# fiber_1 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_1.add_silica_pure_cladding()
# fiber_1.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19) # or 0.15
# fiber_1.create_and_add_new_structure(name='core', radius=11.0e-6 / 2, NA=0.14)

custom_fiber_3.create_and_add_new_structure(
radius=2.75e-6,
NA=0.14,
name='core'
)
# fiber_2 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_2.add_silica_pure_cladding()
# fiber_2.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19) # or 0.15
# fiber_2.create_and_add_new_structure(name='core', radius=13.0e-6 / 2, NA=0.14)

fiber_list = [
custom_fiber_1,
custom_fiber_2,
custom_fiber_3
]
# fiber_configuration_1 = [
# fiber_0, fiber_1, fiber_2
# ]


# %%
# Defining the boundaries of the system
boundaries = [
Boundaries(),
]
# fiber_0 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_0.add_silica_pure_cladding()
# fiber_0.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19)
# fiber_0.create_and_add_new_structure(name='core', radius=9.0e-6 / 2, NA=0.14)

# fiber_1 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_1.add_silica_pure_cladding()
# fiber_1.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19)
# fiber_1.create_and_add_new_structure(name='core', radius=11.0e-6 / 2, NA=0.14)

# fiber_2 = fiber_catalogue.GenericFiber(wavelength=wavelength)
# fiber_2.add_silica_pure_cladding()
# fiber_2.create_and_add_new_structure(name='core', radius=30.0e-6 / 2, NA=0.19)
# fiber_2.create_and_add_new_structure(name='core', radius=13.0e-6 / 2, NA=0.14)

# fiber_configuration_1 = [
# fiber_catalogue.load_fiber('DCF1300S_42', wavelength=wavelength),
# fiber_catalogue.load_fiber('DCF1300S_20', wavelength=wavelength),
# fiber_catalogue.load_fiber('DCF1300S_26', wavelength=wavelength),
# ]


clad_profile = configuration.ring.FusedProfile_03x03

capillary_tube = fiber_catalogue.CapillaryTube(
radius=150e-6,
wavelength=wavelength,
delta_n=-15e-3
)


# %%
# Generating the computing workflow
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Workflow class to define all the computation parameters before initializing the solver
workflow = Workflow(
fiber_list=fiber_list, # List of fiber to be added in the mesh, the order matters.
clad_structure=clad_structure, # Cladding structure, if None provided then no cladding is set.
fusion_degree=0.8, # Degree of fusion of the structure if applicable.
fiber_list=fiber_configuration_0, # List of fiber to be added in the mesh, the order matters.
clad_structure=clad_profile, # Cladding structure, if None provided then no cladding is set.
capillary_tube=capillary_tube, # In this case we add a wrapping capillary tube around the fused structure.
fusion_degree='auto', # Degree of fusion of the structure if applicable.
wavelength=wavelength, # Wavelength used for the mode computation.
resolution=220, # Number of point in the x and y axis [is divided by half if symmetric or anti-symmetric boundaries].
resolution=140, # Number of point in the x and y axis [is divided by half if symmetric or anti-symmetric boundaries].
x_bounds="centering", # Mesh x-boundary structure.
y_bounds="centering", # Mesh y-boundary structure.
boundaries=boundaries, # Set of symmetries to be evaluated, each symmetry add a round of simulation
n_sorted_mode=5, # Total computed and sorted mode.
n_added_mode=5, # Additional computed mode that are not considered later except for field comparison [the higher the better but the slower].
plot_geometry=True, # Plot the geometry mesh before computation.
air_padding_factor=1.1,
debug_mode=2, # Print the iteration step for the solver plus some other important steps.
boundaries=[Boundaries()], # Set of symmetries to be evaluated, each symmetry add a round of simulation
n_sorted_mode=4, # Total computed and sorted mode.
n_added_mode=3, # Additional computed mode that are not considered later except for field comparison [the higher the better but the slower].
# plot_geometry=True, # Plot the geometry mesh before computation.
plot_field=True,
debug_mode=1, # Define the degree of debug printout, from 0 to 3. [Does not work properly on jupyter notebooks]
auto_label=True, # Auto labeling the mode. Label are not always correct and should be verified afterwards.
itr_final=0.01, # Final value of inverse taper ratio to simulate
clad_rotation=0, # Rotate the geoemtry in the given angle in degree
index_scrambling=1e-7 # Scrambling of refractive index value in order to lift mode degeneracy [useful for some analysis]
itr_final=0.05, # Final value of inverse taper ratio to simulate
itr_initial=1.00,
n_step=500,
index_scrambling=0e-4 # Scrambling of refractive index value in order to lift mode degeneracy [useful for some analysis]
)

superset = workflow.get_superset()

# # %%
# # Field computation: :math:`E_{i,j}`
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# _ = superset.plot(plot_type='field', slice_list=[], itr_list=[1.0, 0.3, 0.01]).show()

# # %%
# # Effective index: :math:`n^{eff}_{i,j}`
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# _ = superset.plot(plot_type='index').show()
profile = AlphaProfile(symmetric=False, add_end_of_taper_section=True)

# # %%
# # Modal normalized coupling: :math:`C_{i,j}`
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# _ = superset.plot(plot_type='normalized-coupling').show()

# # %%
# # Adiabatic criterion: :math:`\tilde{C}_{i,j}`
# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# _ = superset.plot(plot_type='adiabatic').show()
profile.add_taper_segment(
alpha=0,
initial_heating_length=2e-3,
stretching_length=0.2e-3 * 20
)

# superset.save_superset_instance()
superset.generate_pdf_report(filename='rodrigo_mames_las_vergas.pdf', directory='auto')
profile.initialize()

# -
superset.plot_adiabatic(add_profile=profile)

0 comments on commit 5591e63

Please sign in to comment.