Ignore:
Timestamp:
09/20/13 07:39:38 (12 years ago)
Author:
cborstad
Message:

CHG: merged matlab changes to python for damage model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/damage.py

    r16179 r16198  
    1616                       
    1717                #damage:
    18                 isdamage = float('NaN')
    19                 self.D   = float('NaN')
    20                 self.law   = ''
     18                self.D                                          = float('NaN')
     19                self.law                                                = ''
     20                self.spcdamage                          = float('NaN')
     21                self.max_damage                 = float('NaN')
    2122               
    22                 #parameters for law 'initial':
    23                 self.stress_threshold    = float('NaN')
    24                 self.c1                  = float('NaN')
    25                 self.c2                  = float('NaN')
    26                 self.c3                  = float('NaN')
    27                 self.c4                  = float('NaN')
     23                #numerical
     24                stabilization                           = float('NaN')
     25                penalty_threshold                       = float('NaN')
     26                maxiter                                         = float('NaN')
     27                penalty_lock                            = float('NaN')
     28                penalty_factor                          = float('NaN')
     29
     30                #general parameters for evolution law:
     31                self.stress_threshold   = float('NaN')
     32                self.c1                 = float('NaN')
     33                self.c2                 = float('NaN')
     34                self.c3                 = float('NaN')
     35                self.c4                 = float('NaN')
     36                self.healing                            = float('NaN')
    2837
    2938                if not len(args):
     
    3847                s+="%s\n" % fielddisplay(self,"D","damage tensor (scalar for now)")
    3948                s+="%s\n" % fielddisplay(self,"law","damage law (string) from ['undamaged','pralong']")
     49                s+="%s\n" % fielddisplay(self,"spcdamage","damage constraints (NaN means no constraint)")
     50                s+="%s\n" % fielddisplay(self,"max_damage","maximum possible damage (0<=max_damage<1)")
     51
     52                s+="%s\n" % fielddisplay(self,"stabilization","0: no, 1: artificial_diffusivity, 2: SUPG")
     53                s+="%s\n" % fielddisplay(self,"maxiter","maximum number of non linear iterations")
     54                s+="%s\n" % fielddisplay(self,"penalty_lock","stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization)")
     55                s+="%s\n" % fielddisplay(self,"penalty_lock","threshold to declare convergence of damage evolution solution (default is 0)")
     56                s+="%s\n" % fielddisplay(self,"penalty_lock","scaling exponent (default is 3)")
    4057
    4158                if (self.law=='pralong'):
     
    5168
    5269                #damage parameters:
    53                 self.isdamage=0
    5470                self.D=0
    5571                self.law='undamaged'
     72
     73                self.max_damage=1-1e-5 #if damage reaches 1, solve becomes singular, as viscosity becomes nil
     74               
     75                #Type of stabilization used
     76                self.stabilization=2
     77                       
     78                #Maximum number of iterations
     79                self.maxiter=100
     80
     81                #factor used to compute the values of the penalties: kappa=max(stiffness matrix)*10^penalty_factor
     82                self.penalty_factor=3
     83                       
     84                #stabilize unstable damage constraints that keep zigzagging after n iteration (default is 0, no stabilization)
     85                self.penalty_lock=0
     86                       
     87                #threshold to declare convergence of thermal solution (default is 0)
     88                self.penalty_threshold=0
     89               
     90                #damage evolution parameters
    5691                self.stress_threshold=0
    5792                self.c1=0
     
    5994                self.c3=0
    6095                self.c4=0
     96                self.healing=0
    6197
    6298        # }}}
    6399        def checkconsistency(self,md,solution,analyses):    # {{{
    64100
    65                 md = checkfield(md,'damage.D','>=',0,'size',[md.mesh.numberofvertices])
    66                 if self.isdamage:
    67                         md = checkfield(md,'damage.law','values',['undamaged','pralong'])
     101                md = checkfield(md,'damage.D','>=',0,'<=',self.max_damage,'size',[md.mesh.numberofvertices])
     102                md = checkfield(md,'damage.max_damage','<',1,'>=',0)
     103                md = checkfield(md,'damage.law','values',['undamaged','pralong'])
     104                md = checkfield(md,'damage.spcdamage','forcing',1)
     105                       
     106                md = checkfield(md,'damage.stabilization','numel',[1],'values',[0,1,2]);
     107                md = checkfield(md,'damage.maxiter','>=0',0);
     108                md = checkfield(md,'damage.penalty_factor','>=0',0);
     109                md = checkfield(md,'damage.penalty_lock','>=0',0);
     110                md = checkfield(md,'damage.penalty_threshold','>=0',0);
     111
    68112                if self.law == 'pralong':
     113                        md = checkfield(md,'damage.healing','>=',0);
    69114                        md = checkfield(md,'damage.c1','>=',0)
    70115                        md = checkfield(md,'damage.c2','>=',0)
     
    72117                        md = checkfield(md,'damage.c4','>=',0)
    73118                        md = checkfield(md,'damage.stress_threshold','>=',0)
     119                elif strcmpi(self.law,'undamaged'):
     120                        if (solution==DamageEvolutionSolutionEnum):
     121                                raise RuntimeError('Invalid evolution law (md.damage.law) for a damage solution');
    74122
    75123                return md
     
    77125        def marshall(self,md,fid):    # {{{
    78126
    79                 WriteData(fid,'object',self,'fieldname','isdamage','format','DoubleMat','mattype',1)
    80127                WriteData(fid,'object',self,'fieldname','D','format','DoubleMat','mattype',1)
    81                 if self.isdamage:
    82                         WriteData(fid,'object',self,'fieldname','law','format','String')
     128                WriteData(fid,'object',self,'fieldname','law','format','String')
     129                WriteData(fid,'object',self,'fieldname','spcdamage','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);
     130                WriteData(fid,'object',self,'fieldname','max_damage','format','Double');
     131
     132                WriteData(fid,'object',self,'fieldname','stabilization','format','Integer');
     133                WriteData(fid,'object',self,'fieldname','penalty_threshold','format','Integer');
     134                WriteData(fid,'object',self,'fieldname','maxiter','format','Integer');
     135                WriteData(fid,'object',self,'fieldname','penalty_lock','format','Integer');
     136                WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double');
     137
    83138                if self.law=='pralong':
    84139                        WriteData(fid,'object',self,'fieldname','c1','format','Double')
Note: See TracChangeset for help on using the changeset viewer.