rsoft_cad package

rsoft_cad.configure_logging(log_file='simulation.log', log_level=20)[source]

Configure logging for the rsoft_cad package.

Parameters:
  • log_file (str) – Path to the log file

  • log_level (int) – Logging level (e.g., logging.INFO, logging.DEBUG)

Subpackages

Submodules

rsoft_cad.constants module

Constants and configuration data for the RSoft CAD package.

rsoft_cad.rsoft_circuit module

class rsoft_cad.rsoft_circuit.RSoftCircuit(params=None, **extra_param)[source]

Bases: object

__init__(params=None, **extra_param)[source]
update_global_params(**params)[source]
add_segment(segment_id=None, **properties)[source]
add_pathways(pathway_id=None, segment_ids=None)[source]
add_pathways_monitor(monitor_id=None, pathway_id=1, **properties)[source]
add_launch_field(launch_id=None, pathway_id=1, **properties)[source]
add_user_taper(user_taper_id=None, **properties)[source]
write(filepath)[source]

Combine all generated circuit elements and write them to a file. Creates the directory if it doesn’t exist.

Parameters: filepath (str): Path to the output file

Returns: bool: True if write was successful, False otherwise

static relative_dist(var_name: str, segment_id: int)[source]
class rsoft_cad.rsoft_circuit.TaperType(taper_type, custom_filename=None)[source]

Bases: object

A class representing a taper profile with optional custom data file.

NONE = 'TAPER_NONE'
LINEAR = 'TAPER_LINEAR'
QUADRATIC = 'TAPER_QUADRATIC'
EXPONENTIAL = 'TAPER_EXPONENTIAL'
USER_PREFIX = 'TAPER_USER_'
__init__(taper_type, custom_filename=None)[source]

Initialize a taper type, optionally with a custom filename.

Parameters:
  • taper_type (str) – The taper type string

  • custom_filename (str, optional) – For user tapers, the filename with taper data

is_user_taper()[source]

Check if this is a user-defined taper that requires a custom file.

classmethod none()[source]

Create a taper with no tapering.

classmethod linear()[source]

Create a linear taper.

classmethod quadratic()[source]

Create a quadratic taper.

classmethod exponential()[source]

Create an exponential taper.

classmethod user(user_number, custom_filename)[source]

Create a user-defined taper with associated data file.

Parameters:
  • user_number (int) – User taper number (1-10)

  • custom_filename (str) – Filename containing taper profile data

Returns:

A user-defined taper type

Return type:

TaperType

class rsoft_cad.rsoft_circuit.LaunchType[source]

Bases: object

FILE = 'LAUNCH_FILE'
COMPUTED_MODE = 'LAUNCH_COMPMODE'
FIBER_MODE = 'LAUNCH_WGMODE'
GAUSSIAN = 'LAUNCH_GAUSSIAN'
RECTANGLE = 'LAUNCH_RECTANGLE'
MULTIMODE = 'LAUNCH_MULTIMODE'
PLANE_WAVE = 'LAUNCH_PLANEWAVE'
class rsoft_cad.rsoft_circuit.MonitorType[source]

Bases: object

FILE_POWER = 'MONITOR_FILE_POWER'
FILE_PHASE = 'MONITOR_FILE_PHASE'
FIBER_POWER = 'MONITOR_WGMODE_POWER'
FIBER_PHASE = 'MONITOR_WGMODE_PHASE'
GAUSS_POWER = 'MONITOR_GAUSS_POWER'
GAUSS_PHASE = 'MONITOR_GAUSS_PHASE'
LAUNCH_POWER = 'MONITOR_LAUNCH_POWER'
LAUNCH_PHASE = 'MONITOR_LAUNCH_PHASE'
PARTIAL_POWER = 'MONITOR_WG_POWER'
TOTAL_POWER = 'MONITOR_TOTAL_POWER'
N_EFF = 'MONITOR_FIELD_NEFF'
FIELD_WIDTH = 'MONITOR_FIELD_WIDTH'
FIELD_HEIGHT = 'MONITOR_FIELD_HEIGHT'
FIELD_AREA = 'MONITOR_FIELD_AEFF'
class rsoft_cad.rsoft_circuit.UserTaper[source]

Bases: object

DATA_FILE = 'UF_DATAFILE'

rsoft_cad.rsoft_simulations module

rsoft_cad.rsoft_simulations.run_simulation(design_filepath: str, design_filename: str, sim_package: str, prefix_name: str, save_folder: str = 'launch_files', hide_sim: bool = True) CompletedProcess[source]

Run simulation for the specified design file and launch mode.

This function executes a simulation for a given photonic lantern design file using the specified simulation package. It creates a target directory for simulation results if it doesn’t exist, changes to that directory to run the simulation, and then returns to the original directory.

Parameters:
  • design_filepath (str) – Path to the directory containing the design file

  • design_filename (str) – Name of the design file to simulate

  • sim_package (str) – Simulation package to use (e.g., ‘femsim’ or ‘bsimw32’)

  • prefix_name (str) – Prefix to use for output files

  • save_folder (str) – Folder name to save simulation results (default: “launch_files”)

  • hide_sim (bool) – Whether to hide the simulation window (default: True)

Returns:

Result of the simulation process, containing stdout, stderr, and return code

Return type:

CompletedProcess

Raises:
rsoft_cad.rsoft_simulations.rename_component_files(directory, file_prefix='femsim', dry_run=False)[source]

Renames files by moving component indicators (ex, ey, ez, etc.) from the end to the beginning.

Parameters:
  • directory (str) – The directory containing files to rename

  • file_prefix (str) – The prefix of files to process (default: “femsim”)

  • dry_run (bool) – If True, only show what would be renamed without actually renaming

Returns:

List of tuples containing (old_filename, new_filename) for renamed files

Return type:

list

rsoft_cad.rsoft_simulations.copy_component_files(directory, file_prefix='femsim', output_directory=None, dry_run=False)[source]

Copies files and moves component indicators (ex, ey, ez, etc.) from the end to the beginning. Original files are preserved.

Parameters:
  • directory (str) – The directory containing files to process

  • file_prefix (str) – The prefix of files to process (default: “femsim”)

  • output_directory (str) – Directory to save new files (default: same as source directory)

  • dry_run (bool) – If True, only show what would be copied without actually copying

Returns:

List of tuples containing (old_filename, new_filename) for copied files

Return type:

list