Crate cherry_rs

Crate cherry_rs 

Source
Expand description

Cherry is a library for sequential optical system design.

The core structure of sequential optical design is the SequentialModel which is a set of submodels containing surfaces and gaps between surfaces. Each SequentialSubModel corresponds to a unique set of system parameters, i.e. a wavelength and a transverse axis. A submodel provides an interface to iterate over the surfaces and gaps in the system.

Inputs to the system are provided by specs, of which there are several types:

  • SurfaceSpec - Describes a surface in the system for which surface sag or paraxial ray trace matrices can be calculated.
  • GapSpec - Describes a gap between surfaces in the system. Refractive index data is located here.
  • ApertureSpec - Describes the aperture of the system. This may differ from any pupils that can be derived directly from the surfaces and gaps.
  • FieldSpec - Describes the field points of the system.
  • RefractiveIndexSpec - Describes the refractive index of a gap.
  • Wavelength - Describes a single wavelength to model.

The outputs of the system are provided by views, such as:

  • ParaxialView - A paraxial view of the system. Contains information such as focal length, principal planes, etc.
  • RayTrace3DView - A 3D ray trace view of the system.
  • CutawayView - A cutaway view of the system. Used primarily for drawing the system.
  • ComponentsView - A view of the components of the system. Used for grouping surfaces into lenses.

§Quick Start

use cherry_rs::{
    n, ray_trace_3d_view, ApertureSpec, FieldSpec, GapSpec, ImagePlane, ParaxialView, Pupil, PupilSampling, RealSpec, RefractiveIndexSpec,
    SequentialModel, SurfaceSpec, SurfaceType,
};

// Create a convexplano lens with an object at infinity.
let air = n!(1.0);
let nbk7 = n!(1.515);

// Define a set of gaps between surfaces.
let gaps = vec![
    GapSpec {
        thickness: f64::INFINITY,
        refractive_index: air.clone(),
    },
    GapSpec {
        thickness: 5.3,
        refractive_index: nbk7,
    },
    GapSpec {
       thickness: 46.6,
       refractive_index: air,
    },
];

// Define a set of surfaces in the system.
let surfaces = vec![
    SurfaceSpec::Object,
    SurfaceSpec::Conic {
        semi_diameter: 12.5,
        radius_of_curvature: 25.8,
        conic_constant: 0.0,
        surf_type: SurfaceType::Refracting,
    },
    SurfaceSpec::Conic {
        semi_diameter: 12.5,
        radius_of_curvature: f64::INFINITY,
        conic_constant: 0.0,
        surf_type: SurfaceType::Refracting,
    },
    SurfaceSpec::Image,
];

// Define a set of wavelengths to model.
let wavelengths: Vec<f64> = vec![0.567];

// Create a sequential model from the gaps, surfaces, and wavelengths.
let sequential_model = SequentialModel::new(&gaps, &surfaces, &wavelengths).unwrap();

// Define a user-defined system aperture.
let aperture_spec = ApertureSpec::EntrancePupil { semi_diameter: 5.0 };

// Analyze the system at two different field points, sampling the pupil
// with a square grid with a spacing of 0.1 in normalized pupil coordinates.
let field_specs = vec![
    FieldSpec::Angle {
        angle: 0.0,
        pupil_sampling: PupilSampling::SquareGrid { spacing: 0.1 },
    },
    FieldSpec::Angle {
        angle: 5.0,
        pupil_sampling: PupilSampling::SquareGrid { spacing: 0.1 },
    },
];

// Compute the paraxial view of the system.
let paraxial_view = ParaxialView::new(&sequential_model, &field_specs, false).unwrap();

// Compute the effective focal length of the lens for each submodel.
for (sub_model_id, _) in sequential_model.submodels() {
    let sub_view = paraxial_view.subviews().get(sub_model_id).unwrap();
    let result = sub_view.effective_focal_length();

    println!("Submodel ID: {:?}, Effective focal length: {}", sub_model_id, result);
}

// Compute a 3D ray trace of the system.
let rays = ray_trace_3d_view(
    &aperture_spec, &field_specs,
    &sequential_model,
    &paraxial_view,
    None,
).unwrap();

Modules§

examples

Macros§

n
Creates a real refractive index spec.

Structs§

CutawayView
A cutaway view through a center transverse plane of a sequential model.
GapSpec
Specifies a gap in a sequential optical system model.
ImagePlane
A paraxial image plane.
ParaxialSubView
A paraxial subview of an optical system.
ParaxialSubViewDescription
A paraxial description of a submodel of an optical system.
ParaxialView
A paraxial view into an optical system.
ParaxialViewDescription
A description of a paraxial optical system.
Pupil
A paraxial entrance or exit pupil.
Ray
A single ray to be traced through an optical system.
RefractiveIndexSpec
Specifies the refractive index of the material constituting a gap.
SequentialModel
A collection of submodels for sequential ray tracing.
SubModelID
A unique identifier for a submodel.
Vec3

Enums§

ApertureSpec
Specifies the system aperture.
Axis
The transverse direction along which system properties will be computed with respect to the reference frame of the system.
Component
A component is a part of an optical system that can interact with light rays.
FieldSpec
Specifies an object field.
ImagSpec
Specifies the imaginary part of a refractive index.
PupilSampling
Specifies a pupil sampling method.
RealSpec
Specifies the real part of a refractive index.
SurfaceSpec
Specifies a surface in a sequential optical system model.
SurfaceType
Specifies the type of interaction of light with a sequential model surface.

Traits§

SequentialSubModel
A submodel of a sequential optical system.

Functions§

components_view
Determine the components of an optical system.
ray_trace_3d_view
Perform a 3D ray trace on a sequential model.

Type Aliases§

Step
A single ray tracing step in a sequential system.
TraceResults
Results of tracing rays through a system.