rsoft_cad.geometry package
This package calculates the geometry of a taper
Submodules
rsoft_cad.geometry.custom_taper module
- rsoft_cad.geometry.custom_taper.sigmoid_taper_ratio(z, taper_length, center1_ratio=0.33, center2_ratio=0.5, center3_ratio=0.67, width1_ratio=0.16666666666666666, width2_ratio=0.1, width3_ratio=0.16666666666666666, weight1=0.1, weight2=0.8, weight3=0.1, min_value=0, max_value=1)[source]
Creates a realistic taper ratio using a weighted combination of three sigmoid functions.
Parameters:
- zarray-like
Position values along the taper
- taper_lengthfloat
Total length of the taper
- center1_ratio, center2_ratio, center3_ratiofloat
Relative positions of sigmoid centers (as fraction of taper_length)
- width1_ratio, width2_ratio, width3_ratiofloat
Relative widths of sigmoids (as fraction of taper_length)
- weight1, weight2, weight3float
Weights for combining the sigmoid functions (should sum to 1)
- min_value, max_valuefloat
Range for clipping the output values
Returns:
- array-like
Taper ratio values
- rsoft_cad.geometry.custom_taper.model_photonic_lantern_taper(z_points=100, taper_length=21.5, cladding_diameter=125, final_cladding_diameter=None, final_capillary_id=150, capillary_id=275, capillary_od=900, layers_config=[(3, 1.0)], core_map=None, core_diameters=None)[source]
Models a photonic lantern taper with support for LP mode mapping and core diameters.
This function extends model_photonic_lantern_taper by adding support for mapping LP modes to fiber positions through the core_map parameter and tracking core diameters along the taper. It renames parameters for clarity and calculates final_cladding_diameter from final_capillary_id if not provided.
Parameters:
- z_pointsint, optional
Number of points along the z-axis. Default is 100.
- taper_lengthfloat, optional
Length of the taper in mm. Default is 21.5.
- cladding_diameterfloat, optional
Initial diameter of the fiber cladding in μm. Default is 125.
- final_cladding_diameterfloat, optional
Final diameter of the fiber claddings in μm. If None, calculated from final_capillary_id.
- final_capillary_idfloat, optional
Final inner diameter of the capillary in μm. Default is 150.
- capillary_idfloat, optional
Initial inner diameter of the capillary in μm. Default is 275.
- capillary_odfloat, optional
Outer diameter of the capillary in μm. Default is 900.
- layers_configlist of tuples, optional
Configuration for fiber layers if core_map is not provided. Default is [(3, 1.0)].
- core_mapdict, optional
Mapping of LP mode names to initial fiber positions. If provided, overrides layers_config. Example: {“LP01”: (0, 0), “LP11a”: (100, 0), “LP11b”: (0, 100)}
- core_diametersdict, optional
Dictionary mapping LP mode names to their initial core diameters in μm. Example: {“LP01”: 10.7, “LP11a”: 9.6, “LP11b”: 9.6} If not provided, all cores default to 80% of the cladding diameter.
Returns:
- dict
A dictionary containing the taper model data with the following keys: - “z”: z-positions along the taper - “fiber_diameters”: Array of fiber (cladding) diameters at each z-position - “core_diameters”: Array of core diameters at each z-position - “fiber_positions”: Array of fiber positions at each z-position - “capillary_inner_diameter”: Inner diameter of the capillary at each z-position - “capillary_outer_diameter”: Outer diameter of the capillary at each z-position - “lp_modes”: List of LP mode names - “mode_positions”: Dictionary mapping LP mode names to their positions along z - “mode_core_diameters”: Dictionary mapping LP mode names to their core diameters along z
- rsoft_cad.geometry.custom_taper.extract_lantern_endpoints(model_output)[source]
Extract endpoint information for the photonic lantern taper model, including cladding, core, and capillary dimensions.
Parameters:
- model_outputdict
The dictionary returned by model_photonic_lantern_taper function
Returns:
- tuple
A tuple of three dictionaries (cladding_endpoints, core_endpoints, cap_endpoints): - cladding_endpoints and core_endpoints contain LP mode information - cap_endpoints contains capillary information with just width and height
Format: {
- “LP01”: {
“end.x”: x_position, “end.y”: y_position, “end.z”: z_position, “end.height”: diameter, “end.width”: diameter
}
cap_endpoints format: {
“end.z”: z_position, “end.height”: inner_diameter, “end.width”: inner_diameter
}
- rsoft_cad.geometry.custom_taper.plot_combined_taper(model, num_cross_sections=6, figsize=(15, 6))[source]
Generates a figure with cross-sections and the longitudinal profile of the taper.
- rsoft_cad.geometry.custom_taper.create_custom_taper_profile(data_dir, expt_dir, taper_func=None, file_name='custom_profile_dim.txt', num_points=300, taper_length=1, z_range=(0, 1), header='/rn,a,b /nx0 100 0 1 1 OUTPUT_REAL\n ', save_to_rsoft_data=True, rsoft_data_dir=None, **taper_func_kwargs)[source]
Create a custom taper profile using sigmoid function and save to file(s).
Parameters:
- data_dirstr
Base directory for data
- expt_dirstr
Experiment directory name
- taper_funccallable, optional
Function to generate the taper profile. Should accept a numpy array of z values as first argument and return a numpy array of taper ratios. If None (default), will use sigmoid_taper_ratio.
- file_namestr, optional
Name of the output file, default is “custom_profile_dim.txt”
- num_pointsint, optional
Number of points in the profile, default is 300
- taper_lengthfloat, optional
Length parameter for the sigmoid taper ratio, default is 1
- z_rangetuple, optional
Range of z values (start, end), default is (0, 1)
- headerstr, optional
Header text for the output file
- save_to_rsoft_databool, optional
Whether to also save to rsoft_data_files subdirectory, default is True
- rsoft_data_dir:
Data directory name.
- **taper_func_kwargs :
Additional keyword arguments to pass to the taper function
Returns:
- tuple
(z, taper_ratios) arrays
rsoft_cad.geometry.tapers module
- rsoft_cad.geometry.tapers.calculate_taper_properties(position, start_dia=None, end_dia=None, taper_length=None, taper_factor=None)[source]
Calculate properties at any point along a tapered section.
Parameters: position (float): Position along the taper where properties are needed start_dia (float, optional): Starting diameter end_dia (float, optional): Ending diameter taper_length (float, optional): Length of the tapered section. Defaults to 100.0 if not provided. taper_factor (float, optional): Ratio of start diameter to end diameter. Can be used instead of providing both diameters.
Returns: tuple: (diameter, taper_rate, taper_factor, end_dia)
diameter (float): Diameter at the specified position
taper_rate (float): Rate of change of diameter per unit length
taper_factor (float): Ratio of start diameter to end diameter
end_dia (float): Ending diameter