svMultiPhysics
Loading...
Searching...
No Matches
ArtificialNeuralNetMaterial.h
1/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2 *
3 * All Rights Reserved.
4 *
5 * See Copyright-SimVascular.txt for additional details.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject
13 * to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* This material model implementation is based on the following paper:
32Peirlinck, M., Hurtado, J.A., Rausch, M.K. et al. A universal material model subroutine
33for soft matter systems. Engineering with Computers 41, 905–927 (2025).
34https://doi.org/10.1007/s00366-024-02031-w */
35
36#ifndef ArtificialNeuralNet_model_H
37#define ArtificialNeuralNet_model_H
38
39#include "mat_fun.h"
40#include "utils.h"
41#include "Parameters.h"
42#include <vector>
43#include "eigen3/Eigen/Core"
44#include "eigen3/Eigen/Dense"
45#include "eigen3/unsupported/Eigen/CXX11/Tensor"
46
47using namespace mat_fun;
48
49// Class for parameter table for material models discovered by constitutive artificial neural network (CANN)
50
51/* This material model implementation is based on the following paper:
52Peirlinck, M., Hurtado, J.A., Rausch, M.K. et al. A universal material model subroutine
53for soft matter systems. Engineering with Computers 41, 905–927 (2025).
54https://doi.org/10.1007/s00366-024-02031-w */
55
57{
58 public:
59
60 // Invariant indices
61 Vector<int> invariant_indices;
62
63 // Activation functions
64 Array<int> activation_functions;
65
66 // Weights
67 Array<double> weights;
68
69 // Number of rows in parameter table
70 int num_rows;
71
72 // Outputs from each layer
73 void uCANN_h0(const double x, const int kf, double &f, double &df, double &ddf) const;
74 void uCANN_h1(const double x, const int kf, const double W, double &f, double &df, double &ddf) const;
75 void uCANN_h2(const double x, const int kf, const double W, double &f, double &df, double &ddf) const;
76
77 // Strain energy and derivatives
78 void uCANN(const double xInv, const int kInv,
79 const int kf0, const int kf1, const int kf2,
80 const double W0, const double W1, const double W2,
81 double &psi, double (&dpsi)[9], double (&ddpsi)[9]) const;
82
83
84 void evaluate(const double aInv[9], double &psi, double (&dpsi)[9], double (&ddpsi)[9]) const;
85
86 // Helper for compute_pk2cc
87 template<size_t nsd>
88 void computeInvariantsAndDerivatives(
89 const Matrix<nsd>& C, const Matrix<nsd>& fl, int nfd, double J2d, double J4d, const Matrix<nsd>& Ci,
90 const Matrix<nsd>& Idm, const double Tfa, Matrix<nsd>& N1, double& psi, double (&Inv)[9], std::array<Matrix<nsd>,9>& dInv,
91 std::array<Tensor<nsd>,9>& ddInv) const;
92
93};
94
95#endif // ArtificialNeuralNet_model_H
Definition ArtificialNeuralNetMaterial.h:57
void uCANN_h1(const double x, const int kf, const double W, double &f, double &df, double &ddf) const
1st layer output of CANN for activation func kf, input x, weight W
Definition ArtificialNeuralNetMaterial.cpp:68
void uCANN(const double xInv, const int kInv, const int kf0, const int kf1, const int kf2, const double W0, const double W1, const double W2, double &psi, double(&dpsi)[9], double(&ddpsi)[9]) const
Updates psi and its derivatives.
Definition ArtificialNeuralNetMaterial.cpp:98
void uCANN_h0(const double x, const int kf, double &f, double &df, double &ddf) const
0th layer output of CANN for activation func kf, input x
Definition ArtificialNeuralNetMaterial.cpp:44
void evaluate(const double aInv[9], double &psi, double(&dpsi)[9], double(&ddpsi)[9]) const
function to build psi and dpsidI1 to 9
Definition ArtificialNeuralNetMaterial.cpp:117
void uCANN_h2(const double x, const int kf, const double W, double &f, double &df, double &ddf) const
2nd layer output of CANN for activation func kf, input x, weight W
Definition ArtificialNeuralNetMaterial.cpp:81
The Vector template class is used for storing int and double data.
Definition Vector.h:50
The classes defined here duplicate the data structures in the Fortran MATFUN module defined in MATFUN...
Definition mat_fun.cpp:41