Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2017-12-03 18:38:18

PATCH
Member
From: Brno, Czech Republic
Registered: 2017-01-03
Posts: 25

Using IF Statements

Hello,
I am working on constitutive model calibration using macro MACR_RECAL and using SIMU_POINT_MAT in slave file. I have stress loading of one material point and I am getting convergence issues. Since I am using MACR_RECAL all calculations must converge and return values. I have been wondering if there is a way of using Python IF statement in case when solution diverges. If the solution will diverge I will return manually created results.

Regards,
PATCH

Offline

#2 2017-12-03 20:16:45

PATCH
Member
From: Brno, Czech Republic
Registered: 2017-01-03
Posts: 25

Re: Using IF Statements

I have figured out the solution. You can use try-except statements and if the solution fails, use predefined results as output (loading it from a file). Here is a snippet of code.

try:
	RESU_S=SIMU_POINT_MAT(COMPORTEMENT=_F(RELATION=MODEL,),
		                  MATER=AA2024,
		                  INCREMENT=_F(LIST_INST=INST_S,),
		                  NEWTON=_F(REAC_ITER=1,),
						  CONVERGENCE=_F (ITER_GLOB_MAXI=40,),
		                  SUPPORT='POINT',
		                  SIGM_IMPOSE=_F(SIXX=S_1,),
		                  INFO=1,);

	RESP_S=CALC_TABLE(TABLE=RESU_S,
		              ACTION=(_F(OPERATION='FILTRE',
		                         NOM_PARA='SIXX',
		                         CRIT_COMP='GE',
		                         VALE=1.0,),
							  _F(OPERATION='FILTRE',
		                         NOM_PARA='INST',
		                         CRIT_COMP='GE',
		                         VALE=TIME_S[-20],),
							  _F(OPERATION='EXTR',
		                         NOM_PARA=('INST','EPXX',),),
								),);
except:
	print('Nastal problem s konvergenci, musim to nahradit FAKE !!!')
	ERR_S=LIRE_FONCTION(INDIC_PARA=(1,1,),
		                 INDIC_RESU=(1,4,),
		                 UNITE=49,
		                 NOM_PARA='INST',
		                 NOM_RESU='EPXX',
		                 INTERPOL='LIN',);

	RESP_S=CREA_TABLE(FONCTION=_F(FONCTION=ERR_S,),);

Regards,
PATCH

Offline

#3 2017-12-04 17:02:21

Johannes_ACKVA
Member
From: Ingenieurbüro für Mechanik, DE
Registered: 2009-11-04
Posts: 646
Website

Re: Using IF Statements

yes, you can use any kind of python syntax. But be aware that not everything is compatible with the .comm -editor eficas ( .comm -editor until versions 13.3 and 12.7 of Code-Aster) or with the new AsterStudy module in Salome (since versions 13.4 and 12.8 of Code-Aster).

Do use any  kind of python syntax you must set in the DEBUT-command:

DEBUT(PAR_LOT='NON')

Regards
Johannes_ACKVA
_________________________________________________________
CODE-ASTER-courses at Ingenieurbüro für Mechanik, Germany

*** CODE-ASTER  INTRODUCTION
     05 Feb - 09 Feb 2018

*** CODE-ASTER  DYNAMIC ANALYSIS
     01 - 02 March 2018


Ingenieurbüro für Mechanik
D 91717 Wassertrüdingen / Germany

www.code-aster.de                                                Training & Support for NASTRAN and CODE-ASTER

Offline

#4 2017-12-07 06:04:20

PATCH
Member
From: Brno, Czech Republic
Registered: 2017-01-03
Posts: 25

Re: Using IF Statements

Yes you are right. Thank you for adding those necessary information especially

DEBUT(PAR_LOT='NON')

Regards,
PATCH

Offline

Board footer