pihnn.nn.enriched_PIHNN#

class pihnn.nn.enriched_PIHNN(PDE, units, boundary, material={'lambda': 1, 'mu': 1}, activation=torch.exp, has_bias=True)#

Bases: DD_PIHNN

PIHNN with enrichment for cracks, as introduced in Calafà et al. [2025].

It is well-known that traditional solvers and NNs face some difficulties to capture the stress field singularities at the cracks. This class hence employs two strategies:

  • Enrichment with Williams approximation (Williams, M., “On the stress distribution at the base of a stationary crack”, 1957).

  • Enrichment with Rice formula (Rice, J. R., “Mathematical Analysis in the Mechanics of Fracture”, 1968).

Parameters:
  • PDE (str) – Problem to solve, either ‘km’ or ‘km-so’.

  • units (list of int) – Number of units at each layer for \(NN_0\), e.g., [1,10,10,1].

  • boundary (pihnn.geometries.boundary) – Geometry of the domain. Needed for information regarding cracks locations and DD partition.

  • material (dict) – Properties of the material, dictionary with ‘lambda’ (first Lamé coefficient), ‘mu’ (second Lamé coefficient).

  • activation (callable) – Activation function, by default the complex exponential.

  • has_bias (bool) – True if the linear layers include bias vectors.

forward(z, flat_output=True, real_output=False, force_williams=False)#

Evaluation of the neural network. This function calls either pihnn.nn.enriched_PIHNN.apply_williams() or pihnn.nn.enriched_PIHNN.apply_rice() based on the setting in pihnn.geometries.boundary.

Parameters:
  • z (torch.tensor) – Input of the network, typically a batch of coordinates from the domain boundary.

  • flat_output (bool) – If True, the output of the network is a 1D/flat vector. Otherwise, the output is a 2D tensor where the first dimension is the number of domains and the second dimension is the number of points per domain. The second option is necessary for the training of the network while one can simply consider a flat output in other circumstances. Notice that the output is flat only if the input is also flat.

  • real_output (bool) – Whether to provide the output in the real-valued representation.

  • force_williams – Intended for internal use, it forces the Williams enrichment on the top of the Rice enrichment.

Returns:

phi (torch.tensor) - Output of the network.

apply_williams(z)#

Application of the Williams approximation.

Namely, the stress field close to a horizontal crack tip at the origin is described by:

\[\begin{split}\begin{cases} \varphi_W(z)= \overline{K}\sqrt{z}, \\ \psi_W(z)= \left(K - \dfrac{\overline{K}}{2}\right)\sqrt{z}, \end{cases}\end{split}\]

where \(K=K_I+iK_{II}\) is the complex number that combines together the stress intensity factors (SIFs) from mixed mode I-II. Here, \(K\) is a trainable parameter and \(\varphi_W,\psi_W\) are suitably transformed in order to take into account crack tips in any position and direction.

Parameters:

z (torch.tensor) – Input of the network, typically a batch of coordinates from the domain boundary.

Returns:

phi (torch.tensor) - Output of the network.

apply_rice(z)#

Application of the Rice formula.

Namely, a stress-free crack is described by the potentials

\[\begin{split}\begin{cases} \varphi(z)=\sqrt{z-a}\sqrt{z+a}f(z) + g(z), \\ \omega(z)= \sqrt{z-a}\sqrt{z+a}\hat{f}(z) - \hat{g}(z), \end{cases}\end{split}\]

where \(\hat{f}(z):=\overline{f(\overline{z})}\), \(\omega(z):=z\varphi'(z) + \psi(z)\), \(f,g\) are two holomorphic functions and

\[\begin{split}\sigma(z) = \begin{cases} \sqrt{z-a}\sqrt{z+a}, & \text{ for an internal crack at } \{x\in[-a,a], y=0\}, \\ \sqrt{z}, & \text{ for an open crack at } \{x\in[-\infty,0], y=0\}. \end{cases}\end{split}\]

The method applies the above representation and applies roto-translations.

Parameters:

z (torch.tensor) – Input of the network, typically a batch of coordinates from the domain boundary.

Returns:

phi (torch.tensor) - Output of the network.