## 2 Background of the Constitutive Metamodel Based on Responses of Representative Volume Elements
Figure 2: Replacing the \(\sigma\rightarrow\varepsilon\) constitutive relation of the RVE by an ANN. Feedforward and Backpropagation in the Neural Model with a Computation of Tangential Stiffness Matrix  
The computational approach initially proposed and presented in [1] uses two neural network metamodels, one for the approximation of the constitutive relation and the second for the approximation of its first derivative, that is, the calculation of the tangential stiffness matrix. Here, following ideas from PINN's community, we construct a neural network based on scientific software Tensorflow v.2.14.0, which provides automatic differentiation for the calculation of the partial derivatives and also enforces material consistency. Two types of neural networks are introduced and trained. The first neural network consists of one residual model and three surrogate models, which are intended to compute the components of the stress tensor \(\sigma_{xx}\), \(\sigma_{yy}\) and \(\sigma_{xy}\) (\(\sigma_{yx}=\sigma_{xy}\)). Namely, there are three NNs with three inputs, strain components \(\epsilon_{xx}\), \(\epsilon_{yy}\) and \(\epsilon_{xy}\) (\(\epsilon_{yx}=\epsilon_{xy}\)) and one output, which is a component of the stress tensor; that is, the first NN has output \(\sigma_{xx}^{NN}\), the second one has output \(\sigma_{yy}^{NN}\) and the third has output \(\sigma_{xy}^{NN}\). The residuals of the outputs are treated simultaneously. The architecture of the proposed bundle of NNs is presented in Figure 4. In the second approach, there exist three separate neural networks for each component of the stress tensor (Figure 5). The loss error function for each output is minimized separately. This can be accomplished because the components of the stress tensor can be computed independently. In the feedforward of the neural network, the output vector for each layer is calculated as follows  
\[z_{0} = (\epsilon_{11},\epsilon_{22},\epsilon_{12})^{T}, \tag{1}\] \[z_{k} = f(W_{k}^{T}z_{k-1}+b_{k}),\;\;k=1,2,...,N_{L}-1,\] (2) \[\sigma_{ij}^{NN}=z_{N_{L}} = W_{N_{L}}^{T}z_{N_{L}-1}+b_{N_{L}},\;\;i,j=1,2,\]  
where \(\epsilon_{11}=\epsilon_{xx}\), \(\epsilon_{12}=\epsilon_{21}=\epsilon_{xy}=\epsilon_{yx}\), \(\epsilon_{22}=\epsilon_{yy}\), \(\sigma_{11}=\sigma_{xx}\), \(\sigma_{12}=\sigma_{21}=\sigma_{xy}=\sigma_{yx}\), \(\sigma_{22}=\sigma_{yy}\), and \(W_{k}^{T}\) is the matrix of the dimension \((n_{k-1}\times n_{k})\), containing the weights between \(k-1\) and \(k\) hidden layers with \(n_{k-1}\) and \(n_{k}\) neurons, respectively. \(W_{N_{L}}^{T}\) is the matrix that contains the weights between the last hidden layer and the output of the neural network. The \(b_{k}\) denote biases. There is no activation function \(f\) for the output layer in the proposed Keras module, but the _tf.keras.layers.Activation_ function  
Figure 3: Plastic deformation of the masonry RVE. can be used to apply a custom activation function to the output if needed, for example, _tf.keras.layers.Activation(tf.mn.relu)_. The residual parts are computed as  
\[MSE=MSE_{\sigma}+MSE_{S}, \tag{3}\]  
where \(MSE_{\sigma}\) is the loss error function while training the data for the strain and stress tensor and \(MSE_{S}\) is the Sobolev loss error function [12]. The residual \(MSE_{\sigma}\) is written as  
\[MSE_{\sigma}=|\sigma_{11}^{NN}-\sigma_{11}^{\text{data}}|+|\sigma_{22}^{NN}- \sigma_{22}^{\text{data}}|+|\sigma_{12}^{NN}-\sigma_{12}^{\text{data}}| \tag{4}\]  
where \(\sigma_{ij}^{NN}=\sigma_{ij}^{NN}(\epsilon_{i}),\ i=1,2\), (\(\sigma_{12}=\sigma_{21}\)) are the output of the neural network, namely, the values of the stress tensor which are computed by the composed constitutive neural network of the variable data set \(\varepsilon=(\varepsilon_{11},\varepsilon_{22},\varepsilon_{12})\), and \(N\) is the number of the values used for fitting the given data set for the stress tensor (samples).