Skip to content

Initial Field

InitialField

Represents an object with various parameters for a beam of light.

Initializes an object with various parameters for a beam of light.

Parameters:

Name Type Description Default
beam_width float

The beam width parameter represents the width of the beam. It determines the spread of the beam and is typically measured as the full width at half maximum (FWHM) of the beam intensity distribution.

required
focal_point tuple

The focal point is the point in space where the beam is focused. It is a coordinate in three-dimensional space (x, y, z) that represents the position of the focal point.

required
field_type str

The field_type parameter specifies the type of field for the beam. It can be set to "gaussian" or any other type of field that is supported by the code. Defaults to "gaussian".

'gaussian'
amplitude float

The amplitude parameter represents the maximum value or intensity of the beam. It determines the overall strength or power of the beam. Defaults to 1.

1
polar_angle float

The polar_angle parameter represents the angle between the positive z-axis and the direction of propagation of the beam. It is measured in radians. Defaults to 0.

0
azimuthal_angle float

The azimuthal angle is a measure of the angle between the projection of the vector onto the xy-plane and the positive x-axis. It determines the orientation of the beam in the xy-plane. Defaults to 0.

0
polarization str

The "polarization" parameter determines the polarization of the beam. It can have two possible values: "TE" for transverse electric polarization and "TM" for transverse magnetic polarization. Defaults to "TE".

'TE'
Source code in yasfpy/initial_field.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def __init__(
    self,
    beam_width,
    focal_point,
    field_type: str = "gaussian",
    amplitude: float = 1,
    polar_angle: float = 0,
    azimuthal_angle: float = 0,
    polarization: str = "TE",
):
    """Initializes an object with various parameters for a beam of light.

    Args:
        beam_width (float): The beam width parameter represents the width of the beam. It determines the spread of the beam
            and is typically measured as the full width at half maximum (FWHM) of the beam intensity
            distribution.
        focal_point (tuple): The focal point is the point in space where the beam is focused. It is a coordinate in
            three-dimensional space (x, y, z) that represents the position of the focal point.
        field_type (str, optional): The `field_type` parameter specifies the type of field for the beam. It can be set to
            "gaussian" or any other type of field that is supported by the code. Defaults to "gaussian".
        amplitude (float, optional): The amplitude parameter represents the maximum value or intensity of the beam. It determines
            the overall strength or power of the beam. Defaults to 1.
        polar_angle (float, optional): The `polar_angle` parameter represents the angle between the positive z-axis and the direction
            of propagation of the beam. It is measured in radians. Defaults to 0.
        azimuthal_angle (float, optional): The azimuthal angle is a measure of the angle between the projection of the vector onto the
            xy-plane and the positive x-axis. It determines the orientation of the beam in the xy-plane. Defaults to 0.
        polarization (str, optional): The "polarization" parameter determines the polarization of the beam. It can have two possible
            values: "TE" for transverse electric polarization and "TM" for transverse magnetic polarization. Defaults to "TE".
    """
    self.field_type = field_type
    self.amplitude = amplitude
    self.polar_angle = polar_angle
    self.azimuthal_angle = azimuthal_angle
    self.polarization = polarization
    self.beam_width = beam_width
    self.focal_point = focal_point

    self.log = log.scattering_logger(__name__)
    self.__setup()

field_type = field_type instance-attribute

amplitude = amplitude instance-attribute

polar_angle = polar_angle instance-attribute

azimuthal_angle = azimuthal_angle instance-attribute

polarization = polarization instance-attribute

beam_width = beam_width instance-attribute

focal_point = focal_point instance-attribute

log = log.scattering_logger(__name__) instance-attribute

__set_pol_idx

Sets the polarization index based on the polarization type.

The polarization index is determined based on the value of the polarization attribute. If the polarization is "unp" or 0, the polarization index is set to 0. If the polarization is "te" or 1, the polarization index is set to 1. If the polarization is "tm" or 2, the polarization index is set to 2. If the polarization is not a valid value, the polarization index is set to 0 and a warning message is logged.

Source code in yasfpy/initial_field.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def __set_pol_idx(self):
    """
    Sets the polarization index based on the polarization type.

    The polarization index is determined based on the value of the `polarization` attribute.
    If the `polarization` is "unp" or 0, the polarization index is set to 0.
    If the `polarization` is "te" or 1, the polarization index is set to 1.
    If the `polarization` is "tm" or 2, the polarization index is set to 2.
    If the `polarization` is not a valid value, the polarization index is set to 0 and a warning message is logged.
    """
    if (
        isinstance(self.polarization, str) and self.polarization.lower() == "unp"
    ) or (isinstance(self.polarization, int) and self.polarization == 0):
        # Unpolarized is also present in the MSTM output
        self.pol = 0
    elif (
        isinstance(self.polarization, str) and self.polarization.lower() == "te"
    ) or (isinstance(self.polarization, int) and self.polarization == 1):
        # Coresponds to the perpendicular value found in MSTM
        self.pol = 1
    elif (
        isinstance(self.polarization, str) and self.polarization.lower() == "tm"
    ) or (isinstance(self.polarization, int) and self.polarization == 2):
        # Coresponds to the parallel value found in MSTM
        self.pol = 2
    else:
        self.pol = 0
        self.log.warning(
            "%s is not a valid polarization type. Please use TE or TM. Reverting to unpolarized",
            self.polarization,
        )

__set_normal_incidence

Sets the normal incidence flag based on the polar angle.

This method checks the value of the polar angle and determines if it is close to zero. If the absolute value of the sine of the polar angle is less than 1e-5, the normal incidence flag is set to True. Otherwise, the normal incidence flag is set to False.

Source code in yasfpy/initial_field.py
81
82
83
84
85
86
87
88
89
def __set_normal_incidence(self):
    """
    Sets the normal incidence flag based on the polar angle.

    This method checks the value of the polar angle and determines if it is close to zero.
    If the absolute value of the sine of the polar angle is less than 1e-5, the normal incidence flag is set to True.
    Otherwise, the normal incidence flag is set to False.
    """
    self.normal_incidence = np.abs(np.sin(self.polar_angle)) < 1e-5

__setup

Performs the initial setup of the field.

This method sets the polarization index and normal incidence for the field.

Source code in yasfpy/initial_field.py
91
92
93
94
95
96
97
98
def __setup(self):
    """
    Performs the initial setup of the field.

    This method sets the polarization index and normal incidence for the field.
    """
    self.__set_pol_idx()
    self.__set_normal_incidence()

Comments