[12038] | 1 | #module imports
|
---|
| 2 | from fielddisplay import fielddisplay
|
---|
| 3 |
|
---|
| 4 | class diagnostic:
|
---|
| 5 | #properties
|
---|
| 6 | def __init__(self):
|
---|
| 7 | # {{{ Properties
|
---|
| 8 | self.spcvx = float('NaN')
|
---|
| 9 | self.spcvy = float('NaN')
|
---|
| 10 | self.spcvz = float('NaN')
|
---|
| 11 | self.restol = 0
|
---|
| 12 | self.reltol = 0
|
---|
| 13 | self.abstol = 0
|
---|
| 14 | self.isnewton = 0
|
---|
| 15 | self.stokesreconditioning = 0
|
---|
| 16 | self.viscosity_overshoot = 0
|
---|
| 17 | self.icefront = float('NaN')
|
---|
| 18 | self.maxiter = 0
|
---|
| 19 | self.shelf_dampening = 0
|
---|
| 20 | self.vertex_pairing = float('NaN')
|
---|
| 21 | self.penalty_factor = float('NaN')
|
---|
| 22 | self.rift_penalty_lock = float('NaN')
|
---|
| 23 | self.rift_penalty_threshold = 0
|
---|
| 24 | self.referential = float('NaN')
|
---|
| 25 | self.requested_outputs = float('NaN')
|
---|
[12123] | 26 |
|
---|
| 27 | #set defaults
|
---|
| 28 | self.setdefaultparameters()
|
---|
| 29 |
|
---|
[12038] | 30 | #}}}
|
---|
| 31 | def __repr__(obj):
|
---|
| 32 | # {{{ Display
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | string='\n Diagnostic solution parameters:'
|
---|
| 36 | string="%s\n\n%s"%(string,' Convergence criteria:')
|
---|
| 37 |
|
---|
| 38 | string="%s\n%s"%(string,fielddisplay(obj,'restol','mechanical equilibrium residual convergence criterion'))
|
---|
| 39 | string="%s\n%s"%(string,fielddisplay(obj,'reltol','velocity relative convergence criterion, NaN -> not applied'))
|
---|
| 40 | string="%s\n%s"%(string,fielddisplay(obj,'abstol','velocity absolute convergence criterion, NaN -> not applied'))
|
---|
| 41 | string="%s\n%s"%(string,fielddisplay(obj,'isnewton','Apply Newton''s method instead of a Picard fixed point method'))
|
---|
| 42 | string="%s\n%s"%(string,fielddisplay(obj,'maxiter','maximum number of nonlinear iterations'))
|
---|
| 43 | string="%s\n%s"%(string,fielddisplay(obj,'viscosity_overshoot','over-shooting constant new=new+C*(new-old)'))
|
---|
| 44 |
|
---|
| 45 | string="%s\n%s"%(string,' boundary conditions:')
|
---|
| 46 |
|
---|
| 47 | string="%s\n%s"%(string,fielddisplay(obj,'spcvx','x-axis velocity constraint (NaN means no constraint)'))
|
---|
| 48 | string="%s\n%s"%(string,fielddisplay(obj,'spcvy','y-axis velocity constraint (NaN means no constraint)'))
|
---|
| 49 | string="%s\n%s"%(string,fielddisplay(obj,'spcvz','z-axis velocity constraint (NaN means no constraint)'))
|
---|
| 50 | string="%s\n%s"%(string,fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice'))
|
---|
| 51 |
|
---|
| 52 | string="%s\n%s"%(string,' Rift options:')
|
---|
| 53 | string="%s\n%s"%(string,fielddisplay(obj,'rift_penalty_threshold','threshold for instability of mechanical constraints'))
|
---|
| 54 | string="%s\n%s"%(string,fielddisplay(obj,'rift_penalty_lock','number of iterations before rift penalties are locked'))
|
---|
| 55 |
|
---|
| 56 | string="%s\n%s"%(string,' Penalty options:')
|
---|
| 57 | string="%s\n%s"%(string,fielddisplay(obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset'))
|
---|
| 58 | string="%s\n%s"%(string,fielddisplay(obj,'vertex_pairing','pairs of vertices that are penalized'))
|
---|
| 59 |
|
---|
| 60 | string="%s\n%s"%(string,' Other:')
|
---|
| 61 | string="%s\n%s"%(string,fielddisplay(obj,'shelf_dampening','use dampening for floating ice ? Only for Stokes model'))
|
---|
| 62 | string="%s\n%s"%(string,fielddisplay(obj,'stokesreconditioning','multiplier for incompressibility equation. Only for Stokes model'))
|
---|
| 63 | string="%s\n%s"%(string,fielddisplay(obj,'referential','local referential'))
|
---|
| 64 | string="%s\n%s"%(string,fielddisplay(obj,'requested_outputs','additional outputs requested'))
|
---|
| 65 |
|
---|
| 66 | return string
|
---|
| 67 | #}}}
|
---|
[12123] | 68 |
|
---|
| 69 | def setdefaultparameters(obj):
|
---|
| 70 | # {{{setdefaultparameters
|
---|
| 71 | #maximum of non-linear iterations.
|
---|
| 72 | obj.maxiter=100
|
---|
| 73 |
|
---|
| 74 | #Convergence criterion: absolute, relative and residual
|
---|
| 75 | obj.restol=10**-4;
|
---|
| 76 | obj.reltol=0.01
|
---|
| 77 | obj.abstol=10
|
---|
| 78 |
|
---|
| 79 | obj.stokesreconditioning=10**13
|
---|
| 80 | obj.shelf_dampening=0
|
---|
| 81 |
|
---|
| 82 | #Penalty factor applied kappa=max(stiffness matrix)*10^penalty_factor
|
---|
| 83 | obj.penalty_factor=3
|
---|
| 84 |
|
---|
| 85 | #coefficient to update the viscosity between each iteration of
|
---|
| 86 | #a diagnostic according to the following formula
|
---|
| 87 | #viscosity(n)=viscosity(n)+viscosity_overshoot(viscosity(n)-viscosity(n-1))
|
---|
| 88 | obj.viscosity_overshoot=0
|
---|
| 89 |
|
---|
| 90 | #Stop the iterations of rift if below a threshold
|
---|
| 91 | obj.rift_penalty_threshold=0
|
---|
| 92 |
|
---|
| 93 | #in some solutions, it might be needed to stop a run when only
|
---|
| 94 | #a few constraints remain unstable. For thermal computation, this
|
---|
| 95 | #parameter is often used.
|
---|
| 96 | obj.rift_penalty_lock=10
|
---|
| 97 |
|
---|
| 98 | return obj
|
---|
| 99 | #}}}
|
---|