# News for constitutive laws

(Difference between revisions)
 Revision as of 15:04, 1 June 2010 (view source)Nelson (Talk | contribs)← Older edit Revision as of 15:06, 1 June 2010 (view source)Nelson (Talk | contribs) Newer edit → Line 182: Line 182: − In the script.py file (main file for running Kratos) we need to import these properties + In the script.py file (main file for running Kratos) we need to import these properties. + The file looks like this from materials import * from materials import * model_part.Properties[1].SetValue(CONSTITUTIVE_LAW, Mat_1) model_part.Properties[1].SetValue(CONSTITUTIVE_LAW, Mat_1)

## Revision as of 15:06, 1 June 2010

The constitutive models are mathematical formulations based on the laws of thermodynamics and the mechanics of continuous medium that predict the behavior of a particular material. In Kratos we program in a file constituting a basis for programming models: constitutive_law.h . It is from this file we can create derived classes that will be our constitutive model.

## C++ files

### Old Format

Usually defines the constructor of a constitutive law with an empty constructor. For example in the elastic constitutive law we write as follows.

``` Isotropic2D::Isotropic2D()
:ConstitutiveLaw< Node<3> >()
{
}
Isotropic2D::~Isotropic2D()
{
}
```

In the element loop, when it call the constitutive law, the element did the follows:

• Update Material
• Calculate Stress
• Calculate Constituve Matrix

```void UpdateMaterial( const Vector& StrainVector,
const Properties& props,
const GeometryType& geom,
const Vector& ShapeFunctionsValues ,
const ProcessInfo& CurrentProcessInfo)
{
}
```
```void Isotropic2D::CalculateElasticMatrix(Matrix& C, const double E, const double NU)
{
double c1 = E / (1.00 - NU*NU);
double c2 = c1 * NU;
double c3 = 0.5*E / (1 + NU);
```
```C(0,0) = c1;	C(0,1) = c2;	C(0,2) = 0.0;
C(1,0) = c2;	C(1,1) = c1;	C(1,2) = 0.0;
C(2,0) = 0.0;	C(2,1) = 0.0;	C(2,2) = c3;
}
```
```void Isotropic2D::CalculateStress(const Vector& StrainVector, Vector& StressVector)
{
double c1 = mE / (1.00 - mNU*mNU);
double c2 = c1 * mNU;
double c3 = 0.5*mE / (1 + mNU);
```
```StressVector[0] = c1*StrainVector[0] + c2 * (StrainVector[1])	;
StressVector[1] = c1*StrainVector[1] + c2 * (StrainVector[0])	;
StressVector[2] = c3*StrainVector[2];
}
```

```void Isotropic2D::CalculateStressAndTangentMatrix(Vector& StressVector, const Vector& StrainVector,Matrix& algorithmicTangent)
{
Isotropic2D::CalculateConstitutiveMatrix(StrainVector, algorithmicTangent);
}
```
```void Isotropic2D::CalculateConstitutiveMatrix(const Vector& StrainVector, Matrix& rResult)
{
CalculateElasticMatrix( rResult, mE, mNU );
}
```

### Proposed New Format

However more complicated constitutive models require defining a number of parameters such as:

• Fluency Criteria
• Softening-Hardening Behavior
• Special Properties
• Other Parameters

Considering this, a constitutive law with these parameters we can define in the constructor as follows:

Variables for the constructor of the constitutive law

```FluencyCriteriaPointer mpFluencyCriteria
SofteningHardeningCriteriaPointer mpSofteningBehavior;
PropertiesPointer mpProperties;
```

``` PlasticDamage2D::PlasticDamage2D()
:ConstitutiveLaw< Node<3> >()
{
KRATOS_ERROR(std::logic_error,"Calling the empty constructor.","");
}
```
``` PlasticDamage2D::PlasticDamage2D(
FluencyCriteriaPointer FluencyCriteria,
SofteningHardeningCriteriaPointer SofteningBehavior,
PropertiesPointer Property)
:ConstitutiveLaw< Node<3> >()
{
mpFluencyCriteria              = FluencyCriteria;
mpSofteningBehavior            = SofteningBehavior;
mpProperties                   = Property;
}
```
``` PlasticDamage2D::~PlasticDamage2D()
{
}
```

Instead of separate calculations of the stresses and constitutive matrix, a new function is included in the base class.

```virtual void CalculateMaterialResponse(
const Vector& StrainVector,
const ProcessInfo& CurrentProcessInfo,
Vector& StressVector,
Matrix& algorithmicTangent,
bool calculate_stress_flag,
bool calculate_tangent_flag,
bool  save_internal_variables)
{
}
```

In the file "add_constitutive_laws_to_python.h" we type:

```class_<PlasticDamage2D, bases< ConstitutiveLawBaseType >, boost::noncopyable >
("PlasticDamage2D",
init<>() )
.def(init<FluencyCriteriaPointer,SofteningHardeningCriteriaPointer, PropertiesPointer>())
.def(init<FluencyCriteriaPointer,FluencyCriteriaPointer, SofteningHardeningCriteriaPointer, PropertiesPointer>())
;
```

As we can see, we can define a constructor with the parameters necessary to define the constitutive law.

## Python files

We need to create an auxiliary file in python to define the materials and other parameters of the constitutive law.

```from Kratos import *
from KratosStructuralApplication import *
```
```# myState.Plane_Stress
# myState.Plane_Strain
# myState.Plane_Trid_D
```
```# myPotencialPlastic.Associated
# myPotencialPlastic.Not_Associated
```
```# Crierios de Fluencia a usar
fluency_1   =  VonMissesYieldFunction(myState.Plane_Stress, myPotencialPlastic.Associated);
```

```#Funcion de Ablandamiento a usar
behavior_1 = LinealSoftening() # ExponentialSoftening()

#Definicion de las propiedades del material
prop_1 = Properties(1)
prop_1.SetValue(DENSITY,2.45E-6);
prop_1.SetValue(POISSON_RATIO, 0.2);
prop_1.SetValue(YOUNG_MODULUS, 3.5E5);
prop_1.SetValue(THICKNESS, 1.00);
prop_1.SetValue(MAX_FRICTION_INTERNAL_ANGLE,30);
prop_1.SetValue(MAX_DILATANCY_ANGLE, 30);
prop_1.SetValue(YIELD_STRESS, 5);
prop_1.SetValue(ISOTROPIC_HARDENING_MODULUS, 0.00);
prop_1.SetValue(KINEMATIC_HARDENING_MODULUS, 0.000);
```

```#definicion de los materiales bases a usar
```
```Mat_1 = PlasticDamage2D(fluency_1, behavior_1, prop_1)
```

In the script.py file (main file for running Kratos) we need to import these properties. The file looks like this

```from materials import *
model_part.Properties[1].SetValue(CONSTITUTIVE_LAW, Mat_1)
```