Skip to content

Input containers¤

Intrinsic modal solution¤

Containers for the intrinsic modal solution settings

DGustMc ¤

Bases: DGust

1-cos gust settings (specialisation from DGust)

Parameters:

Name Type Description Default
u_inf float

Flow velocity

required
simulation_time Array

Time array for the simulation

required
intensity float

Gust intensity

required
step float

Gust discretisation in x-direction -gust dx

required
time_epsilon

Epsilon time between the gust first hitting the AC and the next interpolation point

required
length float

Gust length

required
shift float

Shift gust position

required
panels_dihedral str | Array

Proportional array with cosines for dihedral

required
collocation_points str | Array

Collocation points coordinates

required
shape str

Span-wise shape

required

Attributes:

Name Type Description
totaltime float

gust_length / u_inf

x Array

Discretisation in flow direction

time Array

Times at which gust quantities are interpolated (driven by step and u_inf)

ntime int

len(time)

Source code in feniax/preprocessor/containers/intrinsicmodal.py
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
@Ddataclass
class DGustMc(DGust):
    """1-cos gust settings (specialisation from DGust)

    Parameters
    ----------
    u_inf : float
         Flow velocity     
    simulation_time : Array
         Time array for the simulation
    intensity : float
         Gust intensity
    step : float
         Gust discretisation in x-direction -gust dx
    time_epsilon: float
         Epsilon time between the gust first hitting the AC and the next interpolation point
    length : float
         Gust length
    shift : float
         Shift gust position
    panels_dihedral : str | jax.Array
         Proportional array with cosines for dihedral 
    collocation_points : str | jax.Array
         Collocation points coordinates
    shape : str
         Span-wise shape

    Attributes
    ----------
    totaltime : float
        gust_length / u_inf
    x : Array
        Discretisation in flow direction
    time : Array
        Times at which gust quantities are interpolated (driven by step and u_inf) 
    ntime : int
        len(time)

    """

    u_inf: float = dfield("", default=None)
    simulation_time: jnp.ndarray = dfield("", default=None)
    intensity: float = dfield("", default=None)
    step: float = dfield("", default=None)
    time_epsilon: float = dfield("", default=1e-6)
    length: float = dfield("", default=None)
    shift: float = dfield("", default=0.0)
    panels_dihedral: str | jnp.ndarray = dfield("", default=None)
    collocation_points: str | jnp.ndarray = dfield("", default=None)
    shape: str = dfield("", default="const")
    totaltime: float = dfield("", init=False)
    x: jnp.ndarray = dfield("", init=False)
    time: jnp.ndarray = dfield("", init=False)
    ntime: int = dfield("", init=False)

    def __post_init__(self):
        if isinstance(self.panels_dihedral, (str, pathlib.Path)):
            object.__setattr__(self, "panels_dihedral", jnp.load(self.panels_dihedral))
        if isinstance(self.collocation_points, (str, pathlib.Path)):
            object.__setattr__(self, "collocation_points", jnp.load(self.collocation_points))

        gust_totaltime, xgust, time, ntime = self._set_gustDiscretization(
            self.intensity,
            self.panels_dihedral,
            self.shift,
            self.step,
            self.simulation_time,
            self.length,
            self.u_inf,
            jnp.min(self.collocation_points[:, 0]),
            jnp.max(self.collocation_points[:, 0]),
        )
        object.__setattr__(self, "totaltime", gust_totaltime)
        object.__setattr__(self, "x", xgust)
        object.__setattr__(self, "time", time)
        object.__setattr__(self, "ntime", ntime)
        # del self.simulation_time
        self._initialize_attributes()

    def _set_gustDiscretization(
        self,
        gust_intensity,
        dihedral,
        gust_shift,
        gust_step,
        simulation_time,
        gust_length,
        u_inf,
        min_collocationpoints,
        max_collocationpoints,
    ):
        #
        gust_totaltime = gust_length / u_inf
        xgust = jnp.arange(
            min_collocationpoints,  # jnp.min(collocation_points[:,0]),
            max_collocationpoints  # jnp.max(collocation_points[:,0]) +
            + gust_length
            + gust_step,
            gust_step,
        )
        time_discretization = (gust_shift + xgust) / u_inf
        if time_discretization[-1] < simulation_time[-1]:
            time = jnp.hstack(
                [
                    time_discretization,
                    time_discretization[-1] + self.time_epsilon,
                    simulation_time[-1],
                ]
            )
        else:
            time = time_discretization
        if time[0] != 0.0:
            time = jnp.hstack([0.0, time[0] - 1e-6, time])
        ntime = len(time)
        # npanels = len(collocation_points)
        return gust_totaltime, xgust, time, ntime

DShard ¤

Bases: DataContainer

Algorithm differentiation settings

Parameters:

Name Type Description Default
function str
required
inputs dict
required
input_type str
required
grad_type str
required
objective_fun str
required
objective_var str
required
objective_args dict
required
_numnodes int
required
_numtime int
required
_numcomponents int
required
label str
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
@Ddataclass
class DShard(DataContainer):
    """Algorithm differentiation settings

    Parameters
    ----------
    function : str
    inputs : dict
    input_type : str
    grad_type : str
    objective_fun : str
    objective_var : str
    objective_args : dict
    _numnodes : int
    _numtime : int
    _numcomponents : int
    label : str

    """

    inputs: dict = dfield("", default=None, yaml_save=False)
    input_type: str = dfield("", default=None, options=ADinputType._member_names_)
    label: str = dfield("", default=None, init=False)

    def __post_init__(self):
        label = ShardinputType[self.input_type.upper()].value
        object.__setattr__(self, "label", label)
        input_class = globals()[f"DShard_{self.input_type.lower()}"]
        object.__setattr__(
            self,
            "inputs",
            initialise_Dclass(
                self.inputs,
                input_class
            ),
        )
        self._initialize_attributes()

DShard_gust1 ¤

Bases: DataContainer

Point forces

Source code in feniax/preprocessor/containers/intrinsicmodal.py
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
@Ddataclass
class DShard_gust1(DataContainer):
    """Point forces

    Parameters
    ----------

    """

    length: jnp.ndarray = dfield("", default=None)
    intensity: jnp.ndarray = dfield("", default=None)
    u_inf: jnp.ndarray = dfield("", default=None)
    rho_inf: jnp.ndarray = dfield("", default=None)
    def __post_init__(self):

        self._initialize_attributes()

DShard_pointforces ¤

Bases: DataContainer

Point forces

Source code in feniax/preprocessor/containers/intrinsicmodal.py
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
@Ddataclass
class DShard_pointforces(DataContainer):
    """Point forces

    Parameters
    ----------

    """

    follower_points: jnp.ndarray = dfield("", default=None)
    follower_interpolation: jnp.ndarray = dfield("", default=None)
    dead_points: jnp.ndarray = dfield("", default=None)
    dead_interpolation: jnp.ndarray = dfield("", default=None)
    gravity: jnp.ndarray = dfield("", default=None)
    gravity_vect: jnp.ndarray = dfield("", default=None)

    def __post_init__(self):

        self._initialize_attributes()

Daero ¤

Bases: DataContainer

Modal aerodynamic settings for each system

Parameters:

Name Type Description Default
u_inf float

Flow velocity

required
rho_inf float

Flow density

required
q_inf float

Flow dynamic pressure

required
c_ref float

Reference chord

required
time Array

Simulation time array

required
qalpha Array
required
qx Array
required
elevator_index Array
required
elevator_link Array
required
approx str

Aero approximation Options = Roger

required
Qk_struct list

Sample frequencies and corresponding AICs for the structure

required
Qk_gust list
required
Qk_controls list
required
Q0_rigid Array
required
A str | Array
required
B str | Array
required
C str | Array
required
D str | Array
required
_controls list
required
poles str | Array

Poles array

required
num_poles int

Number of poles

required
gust_profile str

Gust name options=["mc"]

required
gust dict | DGust

Gust settings

required
controller_name dict
required
controller_settings dict
required
controller DController
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
@Ddataclass
class Daero(DataContainer):
    """Modal aerodynamic settings for each system

    Parameters
    ----------
    u_inf : float
        Flow velocity
    rho_inf : float
        Flow density
    q_inf : float
        Flow dynamic pressure
    c_ref : float
        Reference chord
    time : Array
        Simulation time array
    qalpha : Array
    qx : Array
    elevator_index : Array
    elevator_link : Array
    approx : str
        Aero approximation Options = Roger
    Qk_struct : list
        Sample frequencies and corresponding AICs for the structure
    Qk_gust : list
    Qk_controls : list
    Q0_rigid : Array
    A : str | jax.Array
    B : str | jax.Array
    C : str | jax.Array
    D : str | jax.Array
    _controls : list
    poles : str | jax.Array
         Poles array
    num_poles : int
         Number of poles
    gust_profile : str
        Gust name options=["mc"]
    gust : dict | __main__.DGust
        Gust settings 
    controller_name : dict
    controller_settings : dict
    controller : DController

    """

    u_inf: float = dfield("", default=None)
    rho_inf: float = dfield("", default=None)
    q_inf: float = dfield("", init=False)
    c_ref: float = dfield("", default=None)
    time: jnp.ndarray = dfield("", default=None, yaml_save=False)
    qalpha: jnp.ndarray = dfield("", default=None)
    qx: jnp.ndarray = dfield("", default=None)
    elevator_index: jnp.ndarray = dfield("", default=None)
    elevator_link: jnp.ndarray = dfield("", default=None)
    #
    approx: str = dfield("", default="Roger")
    Qk_struct: list[jnp.ndarray, jnp.ndarray] = dfield(
        "",
        default=None,
        yaml_save=False,
    )
    Qk_gust: list[jnp.ndarray, jnp.ndarray] = dfield("", default=None, yaml_save=False)
    Qk_controls: list[jnp.ndarray, jnp.ndarray] = dfield("", default=None, yaml_save=False)
    Q0_rigid: jnp.ndarray = dfield("", default=None, yaml_save=False)
    A: str | jnp.ndarray = dfield("", default=None, yaml_save=False)
    B: str | jnp.ndarray = dfield("", default=None, yaml_save=False)
    C: str | jnp.ndarray = dfield("", default=None, yaml_save=False)
    D: str | jnp.ndarray = dfield("", default=None, yaml_save=False)
    _controls: list[jnp.ndarray, jnp.ndarray] = dfield("", default=None)
    poles: str | jnp.ndarray = dfield("", default=None)
    num_poles: int = dfield("", default=None)
    gust_profile: str = dfield("", default="mc", options=["mc"])
    # gust_settings: dict = dfield("", default=None, yaml_save=False)
    gust: dict | DGust = dfield("Gust settings", default=None)
    controller_name: dict = dfield("", default=None)
    controller_settings: dict = dfield("", default=None)
    controller: DController = dfield("", init=False)

    def __post_init__(self):
        object.__setattr__(self, "approx", self.approx.capitalize())
        if self.gust is not None:
            gust_class = globals()[f"DGust{self.gust_profile.capitalize()}"]
            object.__setattr__(
                self,
                "gust",
                # initialise_Dclass(self.gust, gust_class))
                initialise_Dclass(
                    self.gust, gust_class, u_inf=self.u_inf, simulation_time=self.time
                ),
            )

        if self.controller_name is not None:
            controller_class = globals()[f"DController{self.controller_name.upper()}"]
            controller_obj = initialise_Dclass(self.controller_settings, controller_class)
            object.__setattr__(self, "controller", controller_obj)
        else:
            object.__setattr__(self, "controller", None)
        if isinstance(self.poles, (str, pathlib.Path)):
            object.__setattr__(self, "poles", jnp.load(self.poles))
        if self.elevator_link is not None:
            object.__setattr__(self, "elevator_link", jnp.array(self.elevator_link))
        if self.elevator_index is not None:
            object.__setattr__(self, "elevator_index", jnp.array(self.elevator_index))
        if self.poles is not None:
            object.__setattr__(self, "num_poles", len(self.poles))
        if self.u_inf is not None and self.rho_inf is not None:
            q_inf = 0.5 * self.rho_inf * self.u_inf**2
            object.__setattr__(self, "q_inf", q_inf)
        if isinstance(self.Q0_rigid, (str, pathlib.Path)):
            object.__setattr__(self, "Q0_rigid", jnp.load(self.Q0_rigid))            
        if isinstance(self.A, (str, pathlib.Path)):
            object.__setattr__(self, "A", jnp.load(self.A))
        if isinstance(self.B, (str, pathlib.Path)):
            object.__setattr__(self, "B", jnp.load(self.B))
        if isinstance(self.C, (str, pathlib.Path)):
            object.__setattr__(self, "C", jnp.load(self.C))
        if isinstance(self.D, (str, pathlib.Path)):
            object.__setattr__(self, "D", jnp.load(self.D))

        self._initialize_attributes()

Dconst ¤

Bases: DataContainer

Constants in the configuration

Parameters:

Name Type Description Default
I3 Array

3x3 Identity matrix

required
e1 Array

3-component vector with beam direction in local frame

required
EMAT Array

3x3 Identity matrix

required

Attributes:

Name Type Description
EMATT Array

Transpose EMAT

Source code in feniax/preprocessor/containers/intrinsicmodal.py
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
@filter_kwargs
@Ddataclass
class Dconst(DataContainer):
    """Constants in the configuration

    Parameters
    ----------
    I3 : Array
       3x3 Identity matrix
    e1 : Array
       3-component vector with beam direction in local frame
    EMAT : Array
       3x3 Identity matrix

    Attributes
    ----------
    EMATT : Array
       Transpose EMAT

    """

    I3: jnp.ndarray = dfield("", default=jnp.eye(3))
    e1: jnp.ndarray = dfield(
        "3-component vector with beam direction in local frame",
        default=jnp.array([1.0, 0.0, 0.0]),
    )
    EMAT: jnp.ndarray = dfield(
        "3x3 Identity matrix",
        default=jnp.array(
            [
                [0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0],
                [0, 0, -1, 0, 0, 0],
                [0, 1, 0, 0, 0, 0],
            ]
        ),
    )
    EMATT: jnp.ndarray = dfield("3x3 Identity matrix", init=False)

    def __post_init__(self):
        object.__setattr__(self, "EMATT", self.EMAT.T)
        self._initialize_attributes()

DdiffraxNewton ¤

Bases: Dlibrary

Settings for Diffrax Newton solver

Parameters:

Name Type Description Default
rtol float
required
atol float
required
max_steps int
required
norm str
required
kappa float
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
@Ddataclass
class DdiffraxNewton(Dlibrary):
    """Settings for Diffrax Newton solver

    Parameters
    ----------
    rtol : float
    atol : float
    max_steps : int
    norm : str
    kappa : float

    """

    rtol: float = dfield("", default=1e-7)
    atol: float = dfield("", default=1e-7)
    max_steps: int = dfield("", default=100)
    norm: str = dfield("", default="linalg_norm")
    kappa: float = dfield("", default=0.01)

    def __post_init__(self):
        object.__setattr__(self, "function", "newton")
        self._initialize_attributes()

DdiffraxOde ¤

Bases: Dlibrary

Settings for Diffrax ODE solvers

Parameters:

Name Type Description Default
root_finder dict
required
stepsize_controller dict
required
solver_name str
required
save_at Array | list
required
max_steps int
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
@filter_kwargs
@Ddataclass
class DdiffraxOde(Dlibrary):
    """Settings for Diffrax ODE solvers

    Parameters
    ----------
    root_finder : dict
    stepsize_controller : dict
    solver_name : str
    save_at : jax.Array | list
    max_steps : int

    """

    root_finder: dict = dfield("", default=None)
    stepsize_controller: dict = dfield("", default=None)
    solver_name: str = dfield("", default="Dopri5")
    save_at: jnp.ndarray | list[float] = dfield("", default=None)
    max_steps: int = dfield("", default=20000)

    def __post_init__(self, **kwargs):
        object.__setattr__(self, "function", "ode")
        self._initialize_attributes()

Ddriver ¤

Bases: DataContainer

Program initialisation settings and trigger of simulations.

Parameters:

Name Type Description Default
typeof str

Driver to manage the simulation options=["intrinsic"]

required
sol_path str | Path

Folder path to save results

required
compute_fem bool

Compute or load presimulation data

required
save_fem bool

Save presimulation data

required
ad_on bool

Algorithm differentiation ON

required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
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
@Ddataclass
class Ddriver(DataContainer):
    """Program initialisation settings and trigger of simulations.

    Parameters
    ----------
    typeof : str
        Driver to manage the simulation options=["intrinsic"]
    sol_path : str | pathlib.Path
        Folder path to save results   
    compute_fem : bool
        Compute or load presimulation data
    save_fem : bool
        Save presimulation data
    ad_on : bool
        Algorithm differentiation ON
    """

    typeof: str = dfield("", default=True, options=["intrinsic"])
    sol_path: str | pathlib.Path = dfield("", default="./")
    compute_fem: bool = dfield("", default=True)
    save_fem: bool = dfield("", default=True)
    ad_on: bool = dfield("", default=False)

    def __post_init__(self):
        if self.sol_path is not None:
            object.__setattr__(self, "sol_path", pathlib.Path(self.sol_path))
        self._initialize_attributes()

Dfem ¤

Bases: DataContainer

Finite Element and discretisation model settings.

Parameters:

Name Type Description Default
connectivity dict | list

Connectivities between components

required
folder str | Path

Folder in which to find Ka, Ma, and grid data (with those names)

required
Ka_name str | Path

Condensed stiffness matrix name

required
Ma_name str | Path

Condensed mass matrix name

required
Ka Array

Condensed stiffness matrix

required
Ma Array

Condensed mass matrix

required
Ka0s Array

Condensed stiffness matrix augmented with 0s

required
Ma0s Array

Condensed mass matrix augmented with 0s

required
num_modes int

Number of modes in the solution

required
eig_type str

Calculation of eigenvalues/vectors options=["scipy", "jax_custom", "inputs, input_memory"]

required
eigenvals Array

EigenValues

required
eigenvecs Array

EigenVectors

required
eig_cutoff float

Cut-off frequency such that eigenvalues smaller than this are set to 0

required
eig_names list

name to load eigenvalues/vectors in folder

required
grid str | Path | Array | DataFrame

Grid file or array with Nodes Coordinates, node ID in the FEM, and associated component

required
Cab_xtol float

Tolerance for building the local frame

required

Attributes:

Name Type Description
df_grid DataFrame

Data Frame associated to Grid file

X Array

Grid coordinates

Xm Array

Grid coordinates mid-points

fe_order list[int] | Array

node ID in the FEM

fe_order_start int

fe_order starting with this index

component_vect list

Array with component associated to each node

dof_vect list

Array with DoF associated to each node (for constrained systems)

num_nodes int

Number of nodes

component_names list

Name of components defining the structure

component_father dict

Map between each component and its father

component_nodes dict

Node indexes of the component

component_names_int tuple

Name of components defining the structure as integers

component_father_int tuple

Map between each component and its father with integers

component_nodes_int tuple

Node indexes of the component

component_chain dict

Dictionary mapping each component to all the components in the load path equilibrium

clamped_nodes list

List of clamped or multibody nodes

freeDoF dict
clampedDoF dict
total_clampedDoF int
constrainedDoF int
prevnodes list

Immediate previous node following

Mavg Array

Matrix for tensor average between adjent nodes

Mdiff Array

Matrix for tensor difference between nodes

Mfe_order Array

Matrix with 1s and 0s that reorders quantities such as eigenvectors in the FE model; nodes in horizontal arrangement.

Mfe_order0s Array
Mload_paths Array

Matrix with with 1s and 0s for the load paths that each node, in vertical arrangement, need to transverse to sum up to a free-end.

Source code in feniax/preprocessor/containers/intrinsicmodal.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
@Ddataclass
class Dfem(DataContainer):
    """Finite Element and discretisation model settings.

    Parameters
    ----------
    connectivity : dict | list
        Connectivities between components
    folder : str | pathlib.Path
        Folder in which to find Ka, Ma, and grid data (with those names)
    Ka_name : str | pathlib.Path
        Condensed stiffness matrix name
    Ma_name : str | pathlib.Path
        Condensed mass matrix name
    Ka : Array
        Condensed stiffness matrix
    Ma : Array
        Condensed mass matrix 
    Ka0s : Array
        Condensed stiffness matrix augmented with 0s
    Ma0s : Array
        Condensed mass matrix augmented with 0s
    num_modes : int
        Number of modes in the solution
    eig_type : str
        Calculation of eigenvalues/vectors options=["scipy", "jax_custom", "inputs, input_memory"]
    eigenvals : Array
        EigenValues
    eigenvecs : Array
        EigenVectors
    eig_cutoff : float
        Cut-off frequency such that eigenvalues smaller than this are set to 0
    eig_names : list
        name to load eigenvalues/vectors in `folder`
    grid : str | pathlib.Path | jax.Array | pandas.core.frame.DataFrame
        Grid file or array with Nodes Coordinates, node ID in the FEM, and associated component
    Cab_xtol : float
        Tolerance for building the local frame

    Attributes
    ----------
    df_grid : DataFrame
        Data Frame associated to Grid file
    X : Array
        Grid coordinates    
    Xm : Array
        Grid coordinates mid-points
    fe_order : list[int] | jax.Array
        node ID in the FEM
    fe_order_start : int
        fe_order starting with this index
    component_vect : list
        Array with component associated to each node
    dof_vect : list
        Array with DoF associated to each node (for constrained systems)
    num_nodes : int
        Number of nodes 
    component_names : list
        Name of components defining the structure
    component_father : dict
        Map between each component and its father
    component_nodes : dict
        Node indexes of the component
    component_names_int : tuple
        Name of components defining the structure as integers
    component_father_int : tuple
        Map between each component and its father with integers
    component_nodes_int : tuple
        Node indexes of the component
    component_chain : dict
        Dictionary mapping each component to all the components in the load path equilibrium 
    clamped_nodes : list
        List of clamped or multibody nodes
    freeDoF : dict
    clampedDoF : dict
    total_clampedDoF : int
    constrainedDoF : int
    prevnodes : list
        Immediate previous node following 
    Mavg : Array
        Matrix for tensor average between adjent nodes
    Mdiff : Array
        Matrix for tensor difference between nodes
    Mfe_order : Array
        Matrix with 1s and 0s that reorders quantities such as eigenvectors in the FE model; nodes in horizontal arrangement.    
    Mfe_order0s : Array
    Mload_paths : Array
        Matrix with with 1s and 0s for the load paths that each node, in vertical arrangement, need to transverse to sum up to a free-end.

    """

    connectivity: dict | list = dfield("")
    folder: str | pathlib.Path = dfield(
        "",
        default=None,
    )  # yaml_save=False)
    Ka_name: str | pathlib.Path = dfield("", default="Ka.npy")
    Ma_name: str | pathlib.Path = dfield("", default="Ma.npy")
    Ka: jnp.ndarray = dfield("", default=None, yaml_save=False)
    Ma: jnp.ndarray = dfield("", default=None, yaml_save=False)
    Ka0s: jnp.ndarray = dfield(
        "", default=None, yaml_save=False
    )
    Ma0s: jnp.ndarray = dfield(
        "", default=None, yaml_save=False
    )
    num_modes: int = dfield("", default=None)
    eig_type: str = dfield(
        "",
        default="scipy",
        options=["scipy", "jax_custom", "inputs, input_memory"],
    )
    eigenvals: jnp.ndarray = dfield("", default=None, yaml_save=False)
    eigenvecs: jnp.ndarray = dfield("", default=None, yaml_save=False)
    eig_cutoff: float = dfield(
        "",
        default=1e-2,
    )  # -jnp.inf?
    eig_names: list[str | pathlib.Path] = dfield(
        "",
        default=["eigenvals.npy", "eigenvecs.npy"],
    )
    grid: str | pathlib.Path | jnp.ndarray | pd.DataFrame = dfield(
        "",
        default="structuralGrid",
    )
    Cab_xtol: float = dfield("", default=1e-4)
    df_grid: pd.DataFrame = dfield("", init=False)
    X: jnp.ndarray = dfield("", default=None, yaml_save=False)
    Xm: jnp.ndarray = dfield("", default=None, init=False)
    fe_order: list[int] | jnp.ndarray = dfield("", default=None)
    fe_order_start: int = dfield("", default=0, yaml_save=False)
    component_vect: list[str] = dfield("", default=None, yaml_save=False)
    dof_vect: list[str] = dfield(
        "", default=None, yaml_save=False
    )
    num_nodes: int = dfield("", init=False)
    component_names: list = dfield("", init=False)
    component_father: dict[str:str] = dfield(
        "", init=False
    )
    component_nodes: dict[str : list[int]] = dfield("", init=False)
    component_names_int: tuple[int] = dfield(
        "", init=False
    )
    component_father_int: tuple[int] = dfield(
        "", init=False
    )
    component_nodes_int: tuple[list[int]] = dfield("", init=False)

    component_chain: dict[str : list[str]] = dfield("", init=False)
    clamped_nodes: list[int] = dfield("", init=False)
    freeDoF: dict[str:list] = dfield("", init=False)
    clampedDoF: dict[str:list] = dfield("", init=False)
    total_clampedDoF: int = dfield("", init=False)
    constrainedDoF: int = dfield(
        "", init=False
    )
    #
    prevnodes: list[int] = dfield("", init=False)
    Mavg: jnp.ndarray = dfield("", init=False)
    Mdiff: jnp.ndarray = dfield("", init=False)
    Mfe_order: jnp.ndarray = dfield(
        "",
        init=False,
    )
    Mfe_order0s: jnp.ndarray = dfield(
        "",
        init=False,
    )
    Mload_paths: jnp.ndarray = dfield(
        "",
        init=False,
    )

    def __post_init__(self):
        # set attributes in frozen instance
        setobj = lambda k, v: object.__setattr__(self, k, v)
        connectivity = geometry.list2dict(self.connectivity)
        setobj("connectivity", connectivity)
        Ka_name, Ma_name, grid = geometry.find_fem(
            self.folder, self.Ka_name, self.Ma_name, self.grid
        )
        setobj("Ka_name", Ka_name)
        setobj("Ma_name", Ma_name)
        setobj("grid", grid)
        if self.folder is not None:
            setobj("folder", pathlib.Path(self.folder).absolute())
        if self.Ka is None:
            if self.folder is None:
                setobj("Ka", load_jnp(self.Ka_name))
            else:
                setobj("Ka", load_jnp(self.folder / self.Ka_name))
        if self.Ma is None:
            if self.folder is None:
                setobj("Ma", load_jnp(self.Ma_name))
            else:
                setobj("Ma", load_jnp(self.folder / self.Ma_name))
                # setobj("Ma", load_jnp(self.Ma_name))
        if self.num_modes is None:
            # full set of modes in the solution
            setobj("num_modes", len(self.Ka))
        if self.folder is None:
            df_grid, X, fe_order, component_vect, dof_vect = geometry.build_grid(
                self.grid,
                self.X,
                self.fe_order,
                self.fe_order_start,
                self.component_vect,
                self.dof_vect,
            )
        else:
            df_grid, X, fe_order, component_vect, dof_vect = geometry.build_grid(
                self.folder / self.grid,
                self.X,
                self.fe_order,
                self.fe_order_start,
                self.component_vect,
                self.dof_vect,
            )
        setobj("df_grid", df_grid)
        setobj("X", X)
        setobj("fe_order", fe_order)
        setobj("component_vect", component_vect)
        setobj("dof_vect", dof_vect)
        num_nodes = len(self.X)
        setobj("num_nodes", num_nodes)
        component_names, component_father = geometry.compute_component_father(self.connectivity)
        setobj("component_names", component_names)
        setobj("component_father", component_father)
        setobj("component_nodes", geometry.compute_component_nodes(self.component_vect))
        setobj(
            "component_chain",
            geometry.compute_component_chain(self.component_names, self.connectivity),
        )
        clamped_nodes, freeDoF, clampedDoF, total_clampedDoF, constrainedDoF = (
            geometry.compute_clamped(self.fe_order.tolist(), self.dof_vect)
        )
        setobj("clamped_nodes", clamped_nodes)
        setobj("freeDoF", freeDoF)
        setobj("clampedDoF", clampedDoF)
        setobj("total_clampedDoF", total_clampedDoF)
        setobj("constrainedDoF", constrainedDoF)
        if constrainedDoF:
            Ka0s, Ma0s = geometry.compute_Mconstrained(
                self.Ka, self.Ma, self.fe_order, clamped_nodes, clampedDoF
            )
            setobj("Ka0s", Ka0s)
            setobj("Ma0s", Ma0s)
        setobj(
            "prevnodes",
            geometry.compute_prevnode(
                self.component_vect, self.component_nodes, self.component_father
            ),
        )
        setobj("Mavg", geometry.compute_Maverage(self.prevnodes, self.num_nodes))
        setobj("Xm", jnp.matmul(self.X.T, self.Mavg))
        setobj("Mdiff", geometry.compute_Mdiff(self.prevnodes, self.num_nodes))
        Mfe_order, Mfe_order0s = geometry.compute_Mfe_order(
            self.fe_order,
            self.clamped_nodes,
            self.freeDoF,
            self.total_clampedDoF,
            self.component_nodes,
            self.component_chain,
            self.num_nodes,
        )
        setobj("Mfe_order", Mfe_order)
        setobj("Mfe_order0s", Mfe_order0s)
        setobj(
            "Mload_paths",
            geometry.compute_Mloadpaths(
                self.component_vect,
                self.component_nodes,
                self.component_chain,
                self.num_nodes,
            ),
        )
        (component_names_int, component_nodes_int, component_father_int) = (
            geometry.convert_components(
                self.component_names, self.component_nodes, self.component_father
            )
        )
        setobj("component_names_int", component_names_int)
        setobj("component_nodes_int", component_nodes_int)
        setobj("component_father_int", component_father_int)
        self._initialize_attributes()

Dlibrary ¤

Bases: DataContainer

Solution library

Source code in feniax/preprocessor/containers/intrinsicmodal.py
870
871
872
873
874
@Ddataclass
class Dlibrary(DataContainer):
    """Solution library"""

    function: str = dfield("Function wrapper calling the library", default=None)

DobjectiveArgs ¤

Bases: Dlibrary

Settings for the objective function in the AD

Parameters:

Name Type Description Default
function str
required
nodes tuple
required
t tuple
required
components tuple
required
axis int
required
_numtime int
required
_numnodes int
required
_numcomponents int
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
@Ddataclass
class DobjectiveArgs(Dlibrary):
    """Settings for the objective function in the AD

    Parameters
    ----------
    function : str
    nodes : tuple
    t : tuple
    components : tuple
    axis : int
    _numtime : int
    _numnodes : int
    _numcomponents : int

    """

    nodes: tuple = dfield("", default=None)
    t: tuple = dfield("", default=None)
    components: tuple = dfield("", default=None)
    axis: int = dfield("", default=None)
    _numtime: int = dfield("", default=None)
    _numnodes: int = dfield("", default=None)
    _numcomponents: int = dfield("", default=6)

    def __post_init__(self):
        if self.nodes is None:
            object.__setattr__(self, "nodes", tuple(range(self._numnodes)))
        if self.t is None:
            object.__setattr__(self, "t", tuple(range(self._numtime)))
        if self.components is None:
            object.__setattr__(self, "components", tuple(range(self._numcomponents)))
        self._initialize_attributes()

Drunge_kuttaOde ¤

Bases: Dlibrary

Solution settings for Runge-Kutta in-house solvers

Parameters:

Name Type Description Default
solver_name str
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
902
903
904
905
906
907
908
909
910
911
912
913
914
915
@Ddataclass
class Drunge_kuttaOde(Dlibrary):
    """Solution settings for Runge-Kutta in-house solvers

    Parameters
    ----------
    solver_name : str
    """

    solver_name: str = dfield("", default="rk4")

    def __post_init__(self):
        object.__setattr__(self, "function", "ode")
        self._initialize_attributes()

Dsimulation ¤

Bases: DataContainer

Simulation settings for the management the way each system is run.

Parameters:

Name Type Description Default
typeof str

Type of simulation ["single", "serial", "parallel"]

required
workflow dict

Dictionary that defines which system is run after which. The default None implies systems are run in order of the input

required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@Ddataclass
class Dsimulation(DataContainer):
    """Simulation settings for the management the way each system is run.

    Parameters
    ----------
    typeof : str
        Type of simulation ["single", "serial", "parallel"]
    workflow : dict
        Dictionary that defines which system is run after which.
        The default None implies systems are run in order of the input
    """

    typeof: str = dfield(
        "", default="single", options=["single", "serial", "parallel"]
    )
    workflow: dict = dfield("",
        default=None,
    )

    def __post_init__(self):
        self._initialize_attributes()

Dsystem ¤

Bases: DataContainer

System settings for the corresponding equations to be solved

Parameters:

Name Type Description Default
name str
required
_fem Dfem
required
solution str
required
target str
required
bc1 str
required
save bool
required
xloads dict | Dxloads
required
aero dict | Daero
required
t0 float
required
t1 float
required
tn int
required
dt float
required
t Array
required
solver_library str
required
solver_function str
required
solver_settings str
required
q0treatment int
required
rb_treatment int
required
nonlinear bool
required
residualise bool
required
residual_modes int
required
label str
required
label_map dict
required
states dict
required
num_states int
required
init_states dict
required
init_mapper dict
required
ad DtoAD
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
@Ddataclass
class Dsystem(DataContainer):
    """System settings for the corresponding equations to be solved

    Parameters
    ----------
    name : str
    _fem : Dfem
    solution : str
    target : str
    bc1 : str
    save : bool
    xloads : dict | __main__.Dxloads
    aero : dict | __main__.Daero
    t0 : float
    t1 : float
    tn : int
    dt : float
    t : Array
    solver_library : str
    solver_function : str
    solver_settings : str
    q0treatment : int
    rb_treatment : int
    nonlinear : bool
    residualise : bool
    residual_modes : int
    label : str
    label_map : dict
    states : dict
    num_states : int
    init_states : dict
    init_mapper : dict
    ad : DtoAD

    """

    name: str = dfield("System name")
    _fem: Dfem = dfield("", default=None, yaml_save=False)
    solution: str = dfield(
        "Type of solution to be solved",
        options=["static", "dynamic", "multibody", "stability"],
    )
    target: str = dfield(
        "The simulation goal of this system",
        default="Level",
        options=SimulationTarget._member_names_,
    )
    bc1: str = dfield(
        "Boundary condition first node",
        default="clamped",
        options=BoundaryCond._member_names_,
    )
    operationalmode: str = dfield(
        "",
        options=["(empty string/default)", "AD", "Shard", "ShardAD"],
        default=""
    )

    save: bool = dfield("Save results of the run system", default=True)
    xloads: dict | Dxloads = dfield("External loads dataclass", default=None)
    aero: dict | Daero = dfield("Aerodynamic dataclass", default=None)
    t0: float = dfield("Initial time", default=0.0)
    t1: float = dfield("Final time", default=1.0)
    tn: int = dfield("Number of time steps", default=None)
    dt: float = dfield("Delta time", default=None)
    t: jnp.ndarray = dfield("Time vector", default=None)
    solver_library: str = dfield("Library solving our system of equations", default=None)
    solver_function: str = dfield(
        "Name for the solver of the previously defined library", default=None
    )
    solver_settings: str = dfield("Settings for the solver", default=None)
    q0treatment: int = dfield(
        """Modal velocities, q1, and modal forces, q2, are the main variables
        in the intrinsic structural description,
        but the steady aerodynamics part needs a displacement component, q0;
        proportional gain to q2 or  integration of velocities q1
        can be used to obtain this.""",
        default=2,
        options=[2, 1],
    )
    rb_treatment: int = dfield(
        """Rigid-body treatment: 1 to use the first node quaternion to track the body
        dynamics (integration of strains thereafter; 2 to use quaternions at every node.)""",
        default=1,
        options=[1, 2],
    )
    nonlinear: bool = dfield(
        """whether to include the nonlinear terms in the eqs. (Gammas)
        and in the integration""",
        default=1,
        options=[1, 0, -1, -2],
    )
    residualise: bool = dfield(
        "average the higher frequency eqs and make them algebraic", default=False
    )
    residual_modes: int = dfield("number of modes to residualise", default=0)
    label: str = dfield("""System label that maps to the solution functional""", default=None)
    label_map: dict = dfield("""label dictionary assigning """, default=None)

    states: dict = dfield("""Dictionary with the state variables.""", default=None)
    num_states: int = dfield("""Total number of states""", default=None)
    init_states: dict[str:list] = dfield(
        """Dictionary with initial conditions for each state""", default=None
    )
    init_mapper: dict[str:str] = dfield(
        """Dictionary mapping states types to functions in initcond""",
        default=dict(q1="velocity", q2="force"),
    )
    ad: dict | DtoAD = dfield("""Dictionary for AD""", default=None)
    shard: dict | DShard = dfield("""Dictionary for parallelisation""", default=None)

    def __post_init__(self):
        if self.t is not None:
            object.__setattr__(self, "t1", self.t[-1])
            if (len_t := len(self.t)) < 2:
                object.__setattr__(self, "dt", 0.0)
            else:
                object.__setattr__(self, "dt", self.t[1] - self.t[0])
            object.__setattr__(self, "tn", len_t)
        else:
            if self.dt is not None and self.tn is not None:
                object.__setattr__(self, "t1", self.t0 + (self.tn - 1) * self.dt)
            elif self.tn is not None and self.t1 is not None:
                object.__setattr__(self, "dt", (self.t1 - self.t0) / (self.tn - 1))
            elif self.t1 is not None and self.dt is not None:
                object.__setattr__(self, "tn", math.ceil((self.t1 - self.t0) / self.dt + 1))
                object.__setattr__(self, "t1", self.t0 + (self.tn - 1) * self.dt)
            object.__setattr__(self, "t", jnp.linspace(self.t0, self.t1, self.tn))

        object.__setattr__(self, "xloads", initialise_Dclass(self.xloads, Dxloads))
        if self.aero is not None:
            object.__setattr__(self, "aero", initialise_Dclass(self.aero, Daero, time=self.t))
        # self.xloads = initialise_Dclass(self.xloads, Dxloads)
        if self.solver_settings is None:
            object.__setattr__(self, "solver_settings", dict())

        libsettings_class = globals()[f"D{self.solver_library}{self.solver_function.capitalize()}"]
        object.__setattr__(
            self,
            "solver_settings",
            initialise_Dclass(self.solver_settings, libsettings_class),
        )
        if self.ad is not None:

            if isinstance(self.ad, dict):
                libsettings_class = globals()["DtoAD"]
                object.__setattr__(
                    self,
                    "ad",
                    initialise_Dclass(
                        self.ad,
                        libsettings_class,
                        _numtime=len(self.t),
                        _numnodes=self._fem.num_nodes,
                    ),
                )
            if self.shard is not None:
                object.__setattr__(self, "operationalmode", "ShardAD")
            else:
                object.__setattr__(self, "operationalmode", "AD")
        elif self.shard is not None:
            object.__setattr__(self, "operationalmode", "Shard")            
            if isinstance(self.shard, dict):
                libsettings_class = globals()["DShard"]
                object.__setattr__(
                    self,
                    "shard",
                    initialise_Dclass(
                        self.shard,
                        libsettings_class,
                        _fem=self._fem,
                        _aero=self._aero,
                    ),
                )

        if self.label is None:
            self.build_label()
        self._initialize_attributes()

    def build_states(self, num_modes: int, num_nodes: int):
        tracker = StateTrack()
        # TODO: keep upgrading/ add residualise
        if self.solution == "static" or self.solution == "staticAD":
            tracker.update(q2=num_modes)
            if self.target.lower() == "trim":
                tracker.update(qx=1)
        elif self.solution == "dynamic" or self.solution == "dynamicAD":
            tracker.update(q1=num_modes, q2=num_modes)
            if self.label_map["aero_sol"] and self.aero.approx.lower() == "roger":
                tracker.update(ql=self.aero.num_poles * num_modes)
            if self.q0treatment == 1:
                tracker.update(q0=num_modes)
            if self.bc1.lower() != "clamped":
                if self.rb_treatment == 1:
                    tracker.update(qr=4)
                elif self.rb_treatment == 2:
                    tracker.update(qr=4 * num_nodes)
        # if self.solution == "static":
        #     state_dict.update(m, kwargs)
        object.__setattr__(self, "states", tracker.states)
        object.__setattr__(self, "num_states", tracker.num_states)

    def build_label(self):
        # WARNING: order dependent for the label
        # nonlinear and residualise should always come last as they are represented
        # with letters
        lmap = dict()
        lmap["soltype"] = SystemSolution[self.solution.upper()].value
        lmap["target"] = SimulationTarget[self.target.upper()].value - 1
        if self.xloads.gravity_forces:
            lmap["gravity"] = "G"
        else:
            lmap["gravity"] = "g"
        lmap["bc1"] = BoundaryCond[self.bc1.upper()].value - 1
        lmap["aero_sol"] = int(self.xloads.modalaero_forces)
        if lmap["aero_sol"] > 0:
            if self.aero.approx.lower() == "roger":
                lmap["aero_sol"] = 1
            elif self.aero.approx.lower() == "loewner":
                lmap["aero_sol"] = 2
            if self.aero.qalpha is None and self.aero.qx is None:
                lmap["aero_steady"] = 0
            elif self.aero.qalpha is not None and self.aero.qx is None:
                lmap["aero_steady"] = 1
            elif self.aero.qalpha is None and self.aero.qx is not None:
                lmap["aero_steady"] = 2
            else:
                lmap["aero_steady"] = 3
            #
            if self.aero.gust is None and self.aero.controller is None:
                lmap["aero_unsteady"] = 0
            elif self.aero.gust is not None and self.aero.controller is None:
                lmap["aero_unsteady"] = 1
            elif self.aero.gust is None and self.aero.controller is not None:
                lmap["aero_unsteady"] = 2
            else:
                lmap["aero_unsteady"] = 3
        else:
            lmap["aero_steady"] = 0
            lmap["aero_unsteady"] = 0
        if self.xloads.follower_forces and self.xloads.dead_forces:
            lmap["point_loads"] = 3
        elif self.xloads.follower_forces:
            lmap["point_loads"] = 1
        elif self.xloads.dead_forces:
            lmap["point_loads"] = 2
        else:
            lmap["point_loads"] = 0
        if self.q0treatment == 2:
            lmap["q0treatment"] = 0
        elif self.q0treatment == 1:
            lmap["q0treatment"] = 1
        if self.nonlinear == 1:
            lmap["nonlinear"] = ""
        elif self.nonlinear == -1:
            lmap["nonlinear"] = "l"
        elif self.nonlinear == -2:
            lmap["nonlinear"] = "L"
        if self.residualise:
            lmap["residualise"] = "r"
        else:
            lmap["residualise"] = ""
        labelx = list(lmap.values())
        label = label_generator(labelx)

        # TODO: label dependent
        object.__setattr__(self, "label_map", lmap)
        object.__setattr__(self, "label", label)  # f"dq_{label}")

Dsystems ¤

Bases: DataContainer

Input setting for the range of systems in the simulation

Parameters:

Name Type Description Default
sett dict
required
mapper dict
required
borrow dict
required
_fem Dfem
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
@Ddataclass
class Dsystems(DataContainer):
    """Input setting for the range of systems in the simulation

    Parameters
    ----------
    sett : dict
    mapper : dict
    borrow : dict
    _fem : Dfem

    Attributes
    ----------


    """

    sett: dict[str:dict] = dfield("Settings ", yaml_save=True)
    mapper: dict[str:Dsystem] = dfield("Dictionary with systems in the simulation", init=False)
    borrow: dict[str:str] = dfield(
        """Borrow settings from another system:
    if there is only one system, then inactive; otherwise default to take settings from
    the first system unless specified.
    """,
        default=None,
    )
    _fem: Dfem = dfield("", default=None, yaml_save=False)

    def __post_init__(self):
        mapper = dict()
        counter = 0
        for k, v in self.sett.items():
            if self.borrow is None:
                # pass self._fem to the system here, the others should already have
                # a reference
                mapper[k] = initialise_Dclass(v, Dsystem, name=k, _fem=self._fem)
            elif isinstance(self.borrow, str):
                assert self.borrow in self.sett.keys(), "borrow not in system names"
                if k == self.borrow:
                    mapper[k] = initialise_Dclass(v, Dsystem, name=k)
                else:
                    v0 = self.sett[self.borrow]
                    mapper[k] = initialise_Dclass(v0, Dsystem, name=k, **v)
            else:
                if k in self.borrow.keys():
                    v0 = self.sett[self.borrow[k]]
                    mapper[k] = initialise_Dclass(v0, Dsystem, name=k, **v)
                else:
                    mapper[k] = initialise_Dclass(v, Dsystem, name=k)

            counter += 1
        object.__setattr__(self, "mapper", mapper)
        self._initialize_attributes()

DtoAD ¤

Bases: Dlibrary

Algorithm differentiation settings

Parameters:

Name Type Description Default
function str
required
inputs dict
required
input_type str
required
grad_type str
required
objective_fun str
required
objective_var str
required
objective_args dict
required
_numnodes int
required
_numtime int
required
_numcomponents int
required
label str
required
Source code in feniax/preprocessor/containers/intrinsicmodal.py
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
@Ddataclass
class DtoAD(Dlibrary):
    """Algorithm differentiation settings

    Parameters
    ----------
    function : str
    inputs : dict
    input_type : str
    grad_type : str
    objective_fun : str
    objective_var : str
    objective_args : dict
    _numnodes : int
    _numtime : int
    _numcomponents : int
    label : str

    """

    inputs: dict = dfield("", default=None, yaml_save=False)
    input_type: str = dfield("", default=None, options=ADinputType._member_names_)
    grad_type: str = dfield(
        "",
        default=None,
        options=[  # "grad", "value_grad",
            "jacrev",
            "jacfwd",
            "value",
        ],
    )
    objective_fun: str = dfield("", default=None)
    objective_var: str = dfield("", default=None)
    objective_args: dict | DobjectiveArgs = dfield("", default=None, yaml_save=False)
    _numnodes: int = dfield("", default=None, yaml_save=False)
    _numtime: int = dfield("", default=None, yaml_save=False)
    _numcomponents: int = dfield("", default=6, yaml_save=False)
    label: str = dfield("", default=None, init=False)

    def __post_init__(self):
        label = ADinputType[self.input_type.upper()].value
        object.__setattr__(self, "label", label)

        object.__setattr__(
            self,
            "objective_args",
            initialise_Dclass(
                self.objective_args,
                DobjectiveArgs,
                _numtime=self._numtime,
                _numnodes=self._numnodes,
                _numcomponents=self._numcomponents,
            ),
        )
        self._initialize_attributes()

Dxloads ¤

Bases: DataContainer

External loads settings for each system

Parameters:

Name Type Description Default
follower_forces bool

Include point follower forces

required
dead_forces bool
required
gravity_forces bool
required
modalaero_forces bool
required
x Array
required
force_follower Array
required
force_dead Array
required
follower_points list
required
dead_points list
required
follower_interpolation list
required
dead_interpolation list
required
gravity float
required
gravity_vect Array
required

Attributes:

Name Type Description
Methods
-------
build_point_follower
build_point_dead
build_gravity
Source code in feniax/preprocessor/containers/intrinsicmodal.py
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
@Ddataclass
class Dxloads(DataContainer):
    """External loads settings for each system

    Parameters
    ----------
    follower_forces : bool
        Include point follower forces
    dead_forces : bool
    gravity_forces : bool
    modalaero_forces : bool
    x : Array
    force_follower : Array
    force_dead : Array
    follower_points : list
    dead_points : list
    follower_interpolation : list
    dead_interpolation : list
    gravity : float
    gravity_vect : Array

    Attributes
    ----------

    Methods
    -------
    build_point_follower
    build_point_dead
    build_gravity

    """

    follower_forces: bool = dfield("", default=False)
    dead_forces: bool = dfield("", default=False)
    gravity_forces: bool = dfield("Include gravity in the analysis", default=False)
    modalaero_forces: bool = dfield("Include aerodynamic forces", default=False)
    x: jnp.ndarray = dfield("x-axis vector for interpolation", default=None)
    force_follower: jnp.ndarray = dfield(
        """Point follower forces
    (len(x)x6xnum_nodes)""",
        default=None,
    )
    force_dead: jnp.ndarray = dfield(
        """Point follower forces
    (len(x)x6xnum_nodes)""",
        default=None,
    )
    follower_points: list[list[int, int]] = dfield(
        "Follower force points [Node, coordinate]",
        default=None,
    )
    dead_points: list[list[int, int]] = dfield(
        "Dead force points [Node, coordinate]",
        default=None,
    )

    follower_interpolation: list[list[float]] = dfield(
        "(Linear) interpolation of the follower forces on t \
        [[f0(t0)..f0(tn)]..[fm(t0)..fm(tn)]]",
        default=None,
    )
    dead_interpolation: list[list[int]] = dfield(
        "(Linear) interpolation of the dead forces on t \
        [[f0(t0)..f0(tn)]..[fm(t0)..fm(tn)]]",
        default=None,
    )

    gravity: float = dfield("gravity force [m/s]", default=9.807)
    gravity_vect: jnp.ndarray = dfield("gravity vector", default=jnp.array([0, 0, -1]))

    # gravity_steps: int = dfield("steps in which gravity is applied in trim simulation",
    #                                    default=1) manage by t
    # label: str = dfield("""Description of the loading type:
    # '1001' = follower point forces, no dead forces, no gravity, aerodynamic forces""",
    #                     init=False)
    def __post_init__(self):
        if self.x is not None:
            object.__setattr__(self, "x", jnp.array(self.x))
        else:
            object.__setattr__(self, "x", jnp.linspace(0, 1, 2))
        # self.label = f"{int(self.follower_forces)}\
        # {int(self.dead_forces)}{self.gravity_forces}{self.aero_forces}"
        self._initialize_attributes()

    def build_point_follower(self, num_nodes, C06ab):
        num_interpol_points = len(self.x)
        forces = jnp.zeros((num_interpol_points, 6, num_nodes))
        num_forces = len(self.follower_interpolation)
        for li in range(num_interpol_points):
            for fi in range(num_forces):
                fnode = self.follower_points[fi][0]
                dim = self.follower_points[fi][1]
                forces = forces.at[li, dim, fnode].set(
                    self.follower_interpolation[fi][li]
                )  # Nx_6_Nn
        force_follower = coordinate_transform(forces, C06ab, jax.lax.Precision.HIGHEST)
        object.__setattr__(self, "force_follower", force_follower)
        # return self.force_follower

    def build_point_dead(self, num_nodes):
        # TODO: add gravity force, also in modes as M@g
        num_interpol_points = len(self.x)
        force_dead = jnp.zeros((num_interpol_points, 6, num_nodes))
        num_forces = len(self.dead_interpolation)
        for li in range(num_interpol_points):
            for fi in range(num_forces):
                fnode = self.dead_points[fi][0]
                dim = self.dead_points[fi][1]
                force_dead = force_dead.at[li, dim, fnode].set(self.dead_interpolation[fi][li])
        object.__setattr__(self, "force_dead", force_dead)
        # return self.force_dead

    def build_gravity(self, Ma, Mfe_order):
        num_nodes = Mfe_order.shape[1] // 6
        num_nodes_out = Mfe_order.shape[0] // 6
        if self.x is not None and len(self.x) > 1:
            len_x = len(self.x)
        else:
            len_x = 2
        # force_gravity = jnp.zeros((2, 6, num_nodes))
        gravity = self.gravity * self.gravity_vect
        gravity_field = jnp.hstack([jnp.hstack([gravity, 0.0, 0.0, 0.0])] * num_nodes)
        _force_gravity = jnp.matmul(Mfe_order, Ma @ gravity_field)
        gravity_interpol = jnp.vstack([xi * _force_gravity for xi in jnp.linspace(0, 1, len_x)]).T
        force_gravity = reshape_field(
            gravity_interpol, len_x, num_nodes_out
        )  # Becomes  (len_x, 6, Nn)
        # num_forces = len(self.dead_interpolation)
        # for li in range(num_interpol_points):
        #     for fi in range(num_forces):
        #         fnode = self.dead_points[fi][0]
        #         dim = self.dead_points[fi][1]
        #         force_dead = force_dead.at[li, dim, fnode].set(
        #             self.dead_interpolation[fi][li])
        object.__setattr__(self, "force_gravity", force_gravity)

generate_docstring(cls) ¤

Generate a docstring for a data class based on its fields.

Source code in feniax/preprocessor/containers/intrinsicmodal.py
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
def generate_docstring(cls: Any) -> Any:
    """
    Generate a docstring for a data class based on its fields.
    """
    if not is_dataclass(cls):
        return cls

    lines = [f"{cls.__name__}:\n"]
    for field in fields(cls):
        field_type = field.type.__name__ if hasattr(field.type, "__name__") else str(field.type)
        lines.append(f"    {field.name} : {field_type}")
        # Here you could add more detailed documentation for each field if needed
    cls.__doc__ = "\n".join(lines)
    return cls

update_docstrings(module) ¤

Update docstrings for all data classes in the given module.

Source code in feniax/preprocessor/containers/intrinsicmodal.py
1464
1465
1466
1467
1468
1469
def update_docstrings(module: Any) -> None:
    """Update docstrings for all data classes in the given module."""
    for name, obj in inspect.getmembers(module):
        if inspect.isclass(obj) and is_dataclass(obj):
            obj = generate_docstring(obj)
            print(obj.__doc__)