## 6 Python Implementation and Usage
### Model Formatting, Job Submission, and Sensitivities (Lines 28-3452)  
The _ModelPreparation_ class modifies the ABAQUS(r) model file (.cae) in order to allow the assignment of material properties and material sections to each individual element, as well as the property update during each iteration. Furthermore, this class requests the output of the strain energies, external work, and node strains if solving a stress-dependent problem. In ABAQUS(r), the strain energies of geometrically nonlinear problems are stored in the variables \"SENER\" and \"PENER\", respectively, for the elastic and plastic strain components. Note that, according to the literature [14; 17; 102; 112], the sensitivity of each element in a geometrically nonlinear compliance-minimization problem is given by the sum of the elastic strain (\(E_{e}^{e}\)) and plastic strain components (\(E_{e}^{p}\)), as described in Equation (67). However, for geometrically linear problems, the plastic strain component is zero, and ABAQUS(r) stores the strain energies in the variable \"ESEDEN\". The external work is only requested for a critical analysis of the result, as it should be equal to the objective function considering no energy dissipation.  
\[\frac{\partial C}{\partial\rho}=E_{e}^{e}+E_{e}^{p}. \tag{67}\]  
The submission of the FEA simulations for the state and adjoint models is managed by the classes _ABAQUSFA_ and _AdjointModel_, respectively. _ABAQUSFA_ is also responsible for determining the sensitivity of the compliance objective function \(\left(\frac{\partial C}{\partial\rho}\right)\), which is stored as the class attribute \"ae\". On the other hand, the _AdjointModel_ class also applies the adjoint loads and determines the stress sensitivity. The stress sensitivity \(\left(\frac{\partial\sigma^{PN}(\rho)}{\partial\rho}\right)\), and its most-relevant intermediate terms (\(\partial\sigma^{PN}_{spf}(\rho)\) and \(\partial\sigma^{PN}_{u}(\rho)\)) are stored as attributes of this class, along with the stress and strain vectors. In particular:  
* \"elmt_stress_sensitivity_continuous\" stores the values of \(\frac{\partial\sigma^{PN}(\rho)}{\partial\rho}\) in a mesh-independent and mesh-independent form, making the comparison of the value of this derivative more suitable for the results obtained through finite differences.  
* \"elmt_stress_sensitivity_discrete\" stores the values of \(\frac{\partial\sigma^{PN}(\rho)}{\partial\rho}\) in a mesh-dependent form, which is more suitable to be used as an input to the optimization algorithms, since they generally do not have access to the information of the mesh used in the FEA model. The difference between discrete and continuous element stress sensitivity is the multiplication by the determinant of the Jacobian matrix.
* \"d_pnorm_spf\" stores the values of \(\partial\sigma^{PN}_{spf}(\rho)\).
* \"d_pnorm_displacement\" stores the values of \(\partial\sigma^{PN}_{u}(\rho)\).
* \"stress_vector\" and \"stress_vector_int\" store the stress vectors determined at the element nodes and integration points.
* \"deformation_vector\" and \"deformation_vector_int\" store the strain vectors determined at the element nodes and integration points.  
The sensitivity of the material constraint is determined by the _material_constraint_sensitivity_ function, accounting for the possibility of having a non-uniform mesh with elements of different sizes and the use of either a volume or mass constraint.