thelfer / tfel

Main repository of TFEL/MFront project
https://thelfer.github.io/tfel/web/index.html
Other
87 stars 40 forks source link

how to write .mfront file #344

Closed fengsim closed 1 year ago

fengsim commented 1 year ago

I use the following steps:

  1. generate libBehaviour.so mfront --interface=generic /usr/local/share/doc/mfront/tests/behaviours/LogarithmicStrainPlasticity2.mfront mfront --obuild

  2. python3 mgis_fenics_finite_strain_elastoplasticity.py

Then I get the following:

StandardStrainBasedBehaviour
SmallStrainKinematic
['Strain'] [6]
['Stress'] [6]
Traceback (most recent call last):
  File "mgis_fenics_finite_strain_elastoplasticity.py", line 115, in <module>
    problem = mf.MFrontNonlinearProblem(u, material, bcs=bc)
  File "/usr/local/lib/python3.8/site-packages/mgis/fenics/nonlinear_problem.py", line 579, in __init__
    AbstractNonlinearProblem.__init__(self,
  File "/usr/local/lib/python3.8/site-packages/mgis/fenics/nonlinear_problem.py", line 74, in __init__
    self.material.set_data_manager(self.quadrature_degree, self.ngauss,
  File "/usr/local/lib/python3.8/site-packages/mgis/fenics/nonlinear_material.py", line 100, in set_data_manager
    self.update_material_properties(degree, mesh)
  File "/usr/local/lib/python3.8/site-packages/mgis/fenics/nonlinear_material.py", line 115, in update_material_properties
    mgis_bv.setMaterialProperty(s, key, value)
RuntimeError: getVariable: no variable named 'YieldStrength'

What is "getVariable: no variable named 'YieldStrength'"?

thelfer commented 1 year ago

Looks like your behaviour does not declare a material property named YieldStrength and that you did try declare it.

fengsim commented 1 year ago

thanks, how to declare YieldStrength? I have the following codes:

material = mf.MFrontNonlinearMaterial("./src/libBehaviour.so", "LogarithmicStrainPlasticity", material_properties={"YieldStress": 250e6, "HardeningSlope": 1e6})

thelfer commented 1 year ago

What happens if you remove the material_properties argument ?

fengsim commented 1 year ago

if i remove YieldStrength and HardingSlope

material = mf.MFrontNonlinearMaterial("./src/libBehaviour.so",
                                      "LogarithmicStrainPlasticity",
                                      material_properties={})

Then I got File "/usr/local/lib/python3.8/site-packages/mgis/fenics/nonlinear_problem.py", line 465, in update_constitutive_law mgis_bv.integrate(self.material.data_manager, self.integration_type, RuntimeError: integrate: no variable named 's0' declared No variable declared.

fengsim commented 1 year ago

Is the problem from LibBehaviour.so?

thelfer commented 1 year ago

Your first mistake was to declare an unexpected material property.

So this is the other possible mistake: you did not declare an expected material property. You must have a look at your MFront file to see what are the expected material properties..

fengsim commented 1 year ago

aha, thanks a lot, i go to see it

fengsim commented 1 year ago

please don't close the issue, if i fixed, I will be back

thelfer commented 1 year ago

To be honest, we proably shall introduce better error messages in mgis.fenics :)

fengsim commented 1 year ago

Now it is fenicsx, we just invited them to give our PhD students a talk.

i checked LogarithmicStrainPlasticity.mfront and it seems lost something.

@DSL IsotropicPlasticMisesFlow;
@Behaviour LogarithmicStrainPlasticity;
@Author    Helfer Thomas;
@Date      5/12/13;

@UMATFiniteStrainStrategy[umat] MieheApelLambrechtLogarithmicStrain;

@MaterialProperty stress s0;
@MaterialProperty stress Et;

@LocalVariable stress R;

@InitLocalVariables{
  // hardening slope
  R  = young*Et/(young-Et);
}

@FlowRule{
  f       = seq-R*p-s0;
  df_dseq = 1;
  df_dp   = -R;
}
fengsim commented 1 year ago

in Elasticity.mfront, i found

// Material properties
@MaterialProperty stress young;
young.setGlossaryName("YoungModulus");
@MaterialProperty real   nu;
nu.setGlossaryName("PoissonRatio");
thelfer commented 1 year ago

You may want to type something like this:

$ mfront-query --material-properties LogarithmicStrainPlasticity.mfront

You'll see that you need to define 4 material properties: YoungModulus, PoissonRatio, s0 and Et. The two first ones are automatically declared by the IsotropicPlasticMisesFlow DSL.

fengsim commented 1 year ago

thanks, i have fixed it. In the example for finite deformation plasticity, we could use mgis_fenics_finite_strain_elastoplasticity.py and at the top of this example, the definition of mfront is given as

@DSL Implicit;

 @Behaviour LogarithmicStrainPlasticity;
 @Author Thomas Helfer/Jérémy Bleyer;
 @Date 07 / 04 / 2020;

 @StrainMeasure Hencky;

 @Algorithm NewtonRaphson;
 @Epsilon 1.e-14;
 @Theta 1;

@MaterialProperty stress s0;
 s0.setGlossaryName("YieldStress");
 @MaterialProperty stress H0;
 H0.setEntryName("HardeningSlope");

 @Brick StandardElastoViscoPlasticity{
   stress_potential : "Hooke" {
        young_modulus : 210e9,
         poisson_ratio : 0.3
         },
   inelastic_flow : "Plastic" {
     criterion : "Mises",
     isotropic_hardening : "Linear" {H : "H0", R0 : "s0"}
   }
 };

We just need to copy it to a .mfront file and use front to compile it to libBehaviour.so and it is OK. Thanks.

thelfer commented 1 year ago

We just need to copy it to a .mfront file and use front to compile it to libBehaviour.so and it is OK.

What you do need to do is to make sure that your script and your MFront file are consistent :)

fengsim commented 1 year ago

thanks a lot! :+1:

fengsim commented 1 year ago

Did you use logarithmic stain in the updated lagrangian method?

thelfer commented 1 year ago

No, definitively not :) See the orginial paper of Miehe for details: https://www.sciencedirect.com/science/article/abs/pii/S0045782502004383

fengsim commented 1 year ago

Now I am working for ale for large deformation and I have finished updated lagrangian method for large displacement and small strain. Now I want to do the algorithm in the book of Bathe, page 616, large strain elastoplastic updated lagrangian hencky formulation.

thelfer commented 1 year ago

In this case, you shall not let MFront handle finite strain. Compile your behaviour under the small strain assumptions and compute the kinematic on the FEniCS side. But to be honest, what would you want to do that ? Miehe's framework has some drawbacks, but it is much more physically sound than any updated lagrangian method IMHO.

fengsim commented 1 year ago

I use the other fem solver to compute the kinematic. I am very familiar with fem codes, so which solver is not important. My major is mathematics, so the constitutive laws from solid mechanics are very complex for me. I have finished small strains and large displacement with small strains for elastoplasticity and compared with Abaqus perfectly. Now the finite strain seems very complex. So i want to use MFront to do the strain-stress with my fem solver. I prefer the work from the book "Comutational Methods for Plasticity Theory and Applications", there is one chapter for details finite strain. Miehe's framework should be new, so we want to begin from the standard way.

We want to generate a ALE solid mechanics solver for our multiscale and large scale computational manufacturing simulation.

fengsim commented 1 year ago

We also want to develop a SDK tool for the development of CAX software with AI and we begin a new open source project "OpenCAXPlus". Now we have already collected and integrated more than 50 open source software for CAD/CAE/CAM/CAI.

thelfer commented 1 year ago

I use the other fem solver to compute the kinematic. I am very familiar with fem codes, so which solver is not important. My major is mathematics, so the constitutive laws from solid mechanics are very complex for me. I have finished small strains and large displacement with small strains for elastoplasticity and compared with Abaqus perfectly. Now the finite strain seems very complex. So i want to use MFront to do the strain-stress with my fem solver. I prefer the work from the book "Comutational Methods for Plasticity Theory and Applications", there is one chapter for details finite strain. Miehe's framework should be new, so we want to begin from the standard way.

We want to generate a ALE solid mechanics solver for our multiscale and large scale computational manufacturing simulation.

So in this case, you have two choices:

  1. Handle the kinematics in your solver. Then, you shall declare a "strain based" behaviour on the MFront side
  2. Handle the kinematics in MFront. In this case, you shall define a "true" finite strain behaviour which gives you access to the deformation gradient at the beginning of the time and the deformation gradient at the end of the time step. You shall then return the Cauchy stress..

In both cases, you can't use @StrainMesure Hencky;...

thelfer commented 1 year ago

We also want to develop a SDK tool for the development of CAX software with AI and we begin a new open source project "OpenCAXPlus". Now we have already collected and integrated more than 50 open source software for CAD/CAE/CAM/CAI.

That sounds ambitious and interesting !

fengsim commented 1 year ago

yes, Website, GUI, Android APP, ... have their own SDK, but CAX software dont' have SDK. I think that this is very useful. This is my idea, hahahaha

fengsim commented 1 year ago

Yes, but in MFront you use Miehe's framework. Is this much different with the book of EA de Souza Neto ...? The book seems simliliar with Simo's paper 1991.

thelfer commented 1 year ago

Yes, but in MFront you use Miehe's framework.

Yes, but you just have to remove @StrainMeasure Hencky;

Is this much different with the book of EA de Souza Neto ...? The book seems simliliar with Simo's paper 1991.

Don't know right know, to be honest.

fengsim commented 1 year ago

Thanks :+1:

thelfer commented 1 year ago

@fengsim Is this issue still relevant ?

fengsim commented 1 year ago

You could close it. Thank you very much !!!