Skip to content

Structure

structure

Structure discipline for the Sobieski's SSBJ use case.

Classes

JAXSobieskiStructure

JAXSobieskiStructure()

Bases: BaseJAXSobieskiDiscipline

Structure discipline for the Sobieski's SSBJ use case.

Initialize the JAXDiscipline.

Source code in src/gemseo_jax/problems/sobieski/structure.py
 45
 46
 47
 48
 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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def __init__(self) -> None:  # noqa: D107
    super().__init__()
    self.__bound1 = array([0.25, 0.25, 0.25, 0.25])
    self.__flag1 = array(
        [[0.95, 1.0, 1.1], [1.05, 1.0, 0.9], [1.05, 1.0, 0.9], [1.05, 1.0, 0.95]],
    )
    self.__s_initial_for_wing_twist = array(
        [
            self.x_initial,
            self.half_span_initial,
            self.aero_center_initial,
            self.lift_initial,
        ],
    )
    self.__s_initial_for_wing_weight = array([self.x_initial])
    self.__bound_secthick = array([0.008])
    self.__flag_secthick = array([[0.95, 1.0, 1.05]])
    self.__flag_stress = array(
        [
            [1.05, 1.0, 0.9],
            [0.95, 1.0, 1.05],
            [1.05, 1.0, 0.9],
            [0.95, 1.0, 1.05],
            [0.95, 1.0, 1.05],
        ],
    )
    self.__s_initial_for_constraints = array(
        [
            self.tc_initial,
            self.lift_initial,
            self.x_initial,
            self.half_span_initial,
            self.aero_center_initial,
        ],
    )

    self.__loc_ones = ones(5) * 0.1
    self.default_input_data["c_0"] = np_array([self.constants[0]])
    self.default_input_data["c_1"] = np_array([self.constants[1]])
    self.default_input_data["c_2"] = np_array([self.constants[2]])
    self._fww_coeff = 5 / 18 * 2 / 3 * 42.5
    self._a0_y12 = 1.0
    self._ai_y12 = array([0.3, -0.3, -0.3, -0.2])
    self.__aij_y12 = array(
        [
            [0.2, 0.0794, 0.16304, 0.1846],
            [0.0794, -0.2, -0.12714, -0.1487],
            [0.16304, -0.12714, -0.2, -0.07314],
            [0.1846, -0.1487, -0.07314, 0.0],
        ],
    )
    self.__a0_f0 = 1.0
    self.__ai_f0 = array([6.25])
    self.__aij_f0 = array([[0.0]])
    self.__a0_g1 = [1.0, 1.0, 1.0, 1.0, 1.0]
    self.__ai_g1 = [
        array([-0.75, 0.5, -0.75, 0.5, 0.5]),
        array([-0.5, 1 / 3, -0.5, 1 / 3, 1 / 3]),
        array([-0.375, 0.25, -0.375, 0.25, 0.25]),
        array([-0.3, 0.2, -0.3, 0.2, 0.2]),
        array([-0.25, 1 / 6, -0.25, 1 / 6, 1 / 6]),
    ]
    self.__aij_g1 = [
        array(
            [
                [-1.25, -0.49625, -1.019, -1.15375, -0.1385],
                [-0.49625, 0.0, 0.0, 0.0, 0.0],
                [-1.019, 0.0, -1.25, -0.457125, -0.002375],
                [-1.15375, 0.0, -0.457125, 0.0, 0.0],
                [-0.1385, 0.0, -0.002375, 0.0, 0.0],
            ],
        ),
        array(
            [
                [-0.55555556, -0.22055556, -0.45288889, -0.51277778, -0.06155556],
                [-0.22055556, 0.0, 0.0, 0.0, 0.0],
                [-0.45288889, 0.0, -0.55555556, -0.20316667, -0.00105556],
                [-0.51277778, 0.0, -0.20316667, 0.0, 0.0],
                [-0.06155556, 0.0, -0.00105556, 0.0, 0.0],
            ],
        ),
        array(
            [
                [-0.3125, -0.1240625, -0.25475, -0.2884375, -0.034625],
                [-0.1240625, 0.0, 0.0, 0.0, 0.0],
                [-0.25475, 0.0, -0.3125, -0.11428125, -0.00059375],
                [-0.2884375, 0.0, -0.11428125, 0.0, 0.0],
                [-0.034625, 0.0, -0.00059375, 0.0, 0.0],
            ],
        ),
        array(
            [
                [-0.2, -0.0794, -0.16304, -0.1846, -0.02216],
                [-0.0794, 0.0, 0.0, 0.0, 0.0],
                [-0.16304, 0.0, -0.2, -0.07314, -0.00038],
                [-0.1846, 0.0, -0.07314, 0.0, 0.0],
                [-0.02216, 0.0, -0.00038, 0.0, 0.0],
            ],
        ),
        array(
            [
                [-0.13888889, -0.05513889, -0.11322222, -0.12819444, -0.01538889],
                [-0.05513889, 0.0, 0.0, 0.0, 0.0],
                [-0.11322222, 0.0, -0.13888889, -0.05079167, -0.00026389],
                [-0.12819444, 0.0, -0.05079167, 0.0, 0.0],
                [-0.01538889, 0.0, -0.00026389, 0.0, 0.0],
            ],
        ),
    ]
Attributes
jax_out_func instance-attribute
jax_out_func: Callable[[DataType], DataType] = function

The JAX function to compute the outputs from the inputs.

Classes
DifferentiationMethod

Bases: StrEnum

The method to compute the Jacobian.

Functions
add_differentiated_inputs
add_differentiated_inputs(
    input_names: Iterable[str] = (),
) -> None

Add the inputs with respect to which to differentiate the outputs.

The inputs that do not represent continuous numbers are filtered out.

Parameters:

  • input_names (Iterable[str], default: () ) –

    The input variables with respect to which to differentiate the outputs. If empty, use all the inputs.

Raises:

  • ValueError

    When an input name is not the name of a discipline input.

Notes

The Jacobian is also filtered to view non-differentiated static.

Source code in src/gemseo_jax/jax_discipline.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
def add_differentiated_inputs(
    self,
    input_names: Iterable[str] = (),
) -> None:
    """
    Notes:
        The Jacobian is also filtered to view non-differentiated static.
    """  # noqa: D205, D212, D415
    old_differentiated_inputs = self._differentiated_input_names.copy()
    super().add_differentiated_inputs(input_names=input_names)
    refilter = any(
        input_name not in old_differentiated_inputs
        for input_name in self._differentiated_input_names
    )
    if refilter:
        self._filter_jacobian()
add_differentiated_outputs
add_differentiated_outputs(
    output_names: Iterable[str] = (),
) -> None

Add the outputs to be differentiated.

The outputs that do not represent continuous numbers are filtered out.

Parameters:

  • output_names (Iterable[str], default: () ) –

    The outputs to be differentiated. If empty, use all the outputs.

Raises:

  • ValueError

    When an output name is not the name of a discipline output.

Notes

The Jacobian is also filtered to view non-differentiated static.

Source code in src/gemseo_jax/jax_discipline.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
def add_differentiated_outputs(
    self,
    output_names: Iterable[str] = (),
) -> None:
    """
    Notes:
        The Jacobian is also filtered to view non-differentiated static.
    """  # noqa: D205, D212, D415
    old_differentiated_outputs = self._differentiated_output_names.copy()
    super().add_differentiated_outputs(output_names=output_names)
    refilter = any(
        output_name not in old_differentiated_outputs
        for output_name in self._differentiated_output_names
    )
    if refilter:
        self._filter_jacobian()
compile_jit
compile_jit(pre_run: bool = True) -> None

Apply jit compilation over function and jacobian.

Parameters:

  • pre_run (bool, default: True ) –

    Whether to call jitted callables once to trigger compilation and log times.

Source code in src/gemseo_jax/jax_discipline.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
def compile_jit(
    self,
    pre_run: bool = True,
) -> None:
    """Apply jit compilation over function and jacobian.

    Args:
        pre_run: Whether to call jitted callables once to trigger compilation and
            log times.
    """
    self.jax_out_func = jit(self.jax_out_func)
    self.__jax_jac_func = jit(self.__jax_jac_func)
    if pre_run:
        self._jit_pre_run()