CoaxialSurfaceSequence

class dnois.optics.rt.CoaxialSurfaceSequence(surfaces: Sequence[Surface] = None, foremost_material: Material | str = 'vacuum', stop_idx: int = None)

A subclass of SurfaceSequence to contain coaxial surfaces.

extra_repr() str

Return the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(ray: BatchedRay, forward: bool = True) BatchedRay

Traces rays incident on the first surface and returns rays passing the last surface, or reversely if forward is False.

Parameters:
  • ray (BatchedRay) – Input rays.

  • forward (bool) – Whether rays are forward or not.

Returns:

Output rays.

Return type:

BatchedRay

freeze(name: str | Sequence[str] = None)

Equivalent to self.set_optimizable(name, False). See set_optimizable().

classmethod from_dict(d: dict)

Constructs an instance of cls from a dict.

Parameters:

d (dict) – A dict typically returned by to_dict().

Returns:

An instance of cls.

classmethod load_json(file, **kwargs) Self

Constructs an instance of cls through loading JSON from a file, converting it to a dict and then calling from_dict().

Parameters:
  • file (str or pathlib.Path or file-like object) – The JSON file to load. Either its path (str or pathlib.Path) or a file-like object.

  • kwargs – Keyword arguments passed to json.load().

Returns:

An instance of cls.

paraxialize(wl: Real | Tensor) ParaxialSystem

Apply paraxialize() to this surface sequence.

reverse()

See SurfaceSequence.reverse().

Warning

The CoaxialContext.distance of the last surface after reversal will be set to 0. Remember to modify it manually if needed.

save_json(file, **kwargs)

Save self into a JSON file file.

Parameters:
  • file – The JSON file to save. Either its path (str or pathlib.Path) or a file-like object.

  • kwargs – Keyword arguments passed to json.dump().

set_optimizable(name: str | Sequence[str] = None, optimizable: bool = True)

Specify whether a parameter is optimizable.

Parameters:
  • name (str) – Name of the parameter. If None, all parameters will be set. It follows the same convention as torch.nn.Module.get_parameter().

  • optimizable (bool) – Whether the specified parameter is optimizable. Default: True.

to_dict(keep_tensor=True) dict[str, Any]

Converts self into a dict which recursively contains only primitive Python objects.

Return type:

dict

to_json(**kwargs) str

Converts self into a JSON string.

Parameters:

kwargs – Keyword arguments passed to json.dumps().

Return type:

str

unfreeze(name: str | Sequence[str] = None)

Equivalent to self.set_optimizable(name, True). See set_optimizable().

property first: Surface

Returns the first surface. This property can be set or deleted.

Type:

Surface.

property is_empty: bool

Whether this list is empty.

Type:

bool

property last: Surface

Returns the last surface. This property can be set or deleted.

Type:

Surface.

property length: Tensor

Returns the distance between baselines of the first and that of the last surfaces as a 0D tensor.

Type:

Tensor

mt_head: mt.Material

Material before the first surface.

property mt_tail: Material

Returns the material after the last surface.

Type:

Material

property stop: CircularStop | None

The aperture stop object. Returns None if no stop is found. Note that it need not return an instance of CircularStop.

Type:

CircularStop or None

property stop_idx: int | None

Index of the aperture stop. Returns None if no stop is found.

Type:

int or None

property total_length: Tensor

Returns the sum of Surface.distance of all the surfaces as a 0D tensor.

Type:

Tensor