Changeset 24313 for issm/trunk/src/m/consistency/ismodelselfconsistent.py
- Timestamp:
- 11/01/19 12:01:57 (5 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/consistency/ismodelselfconsistent.py
r22758 r24313 1 def AnalysisConfiguration(solutiontype): #{{{2 3 ANALYSISCONFIGURATION - return type of analyses, number of analyses 1 def AnalysisConfiguration(solutiontype): #{{{ 2 """ 3 ANALYSISCONFIGURATION - return type of analyses, number of analyses 4 4 5 6 [analyses]=AnalysisConfiguration(solutiontype); 7 5 Usage: 6 [analyses] = AnalysisConfiguration(solutiontype) 7 """ 8 8 9 if solutiontype == 'StressbalanceSolution': 10 analyses=['StressbalanceAnalysis','StressbalanceVerticalAnalysis','StressbalanceSIAAnalysis','L2ProjectionBaseAnalysis'] 9 if solutiontype == 'StressbalanceSolution': 10 analyses = ['StressbalanceAnalysis', 'StressbalanceVerticalAnalysis', 'StressbalanceSIAAnalysis', 'L2ProjectionBaseAnalysis'] 11 elif solutiontype == 'SteadystateSolution': 12 analyses = ['StressbalanceAnalysis', 'StressbalanceVerticalAnalysis', 'StressbalanceSIAAnalysis', 'L2ProjectionBaseAnalysis', 'ThermalAnalysis', 'MeltingAnalysis', 'EnthalpyAnalysis'] 13 elif solutiontype == 'ThermalSolution': 14 analyses = ['EnthalpyAnalysis', 'ThermalAnalysis', 'MeltingAnalysis'] 15 elif solutiontype == 'MasstransportSolution': 16 analyses = ['MasstransportAnalysis'] 17 elif solutiontype == 'BalancethicknessSolution': 18 analyses = ['BalancethicknessAnalysis'] 19 elif solutiontype == 'SurfaceSlopeSolution': 20 analyses = ['L2ProjectionBaseAnalysis'] 21 elif solutiontype == 'BalancevelocitySolution': 22 analyses = ['BalancevelocityAnalysis'] 23 elif solutiontype == 'BedSlopeSolution': 24 analyses = ['L2ProjectionBaseAnalysis'] 25 elif solutiontype == 'GiaSolution': 26 analyses = ['GiaIvinsAnalysis'] 27 elif solutiontype == 'LoveSolution': 28 analyses = ['LoveAnalysis'] 29 elif solutiontype == 'TransientSolution': 30 analyses = ['StressbalanceAnalysis', 'StressbalanceVerticalAnalysis', 'StressbalanceSIAAnalysis', 'L2ProjectionBaseAnalysis', 'ThermalAnalysis', 'MeltingAnalysis', 'EnthalpyAnalysis', 'MasstransportAnalysis', 'HydrologyShaktiAnalysis', 'HydrologyGladsAnalysis', 'HydrologyDCInefficientAnalysis', 'HydrologyDCEfficientAnalysis'] 31 elif solutiontype == 'HydrologySolution': 32 analyses = ['L2ProjectionBaseAnalysis', 'HydrologyShreveAnalysis', 'HydrologyDCInefficientAnalysis', 'HydrologyDCEfficientAnalysis'] 33 elif 'DamageEvolutionSolution': 34 analyses = ['DamageEvolutionAnalysis'] 11 35 12 elif solutiontype == 'SteadystateSolution': 13 analyses=['StressbalanceAnalysis','StressbalanceVerticalAnalysis','StressbalanceSIAAnalysis','L2ProjectionBaseAnalysis','ThermalAnalysis','MeltingAnalysis','EnthalpyAnalysis'] 36 else: 37 raise TypeError("solution type: '%s' not supported yet!" % solutiontype) 38 return analyses 39 #}}} 14 40 15 elif solutiontype == 'ThermalSolution':16 analyses=['EnthalpyAnalysis','ThermalAnalysis','MeltingAnalysis']17 18 elif solutiontype == 'MasstransportSolution':19 analyses=['MasstransportAnalysis']20 21 elif solutiontype == 'BalancethicknessSolution':22 analyses=['BalancethicknessAnalysis']23 24 elif solutiontype == 'SurfaceSlopeSolution':25 analyses=['L2ProjectionBaseAnalysis']26 27 elif solutiontype == 'BalancevelocitySolution':28 analyses=['BalancevelocityAnalysis']29 30 elif solutiontype == 'BedSlopeSolution':31 analyses=['L2ProjectionBaseAnalysis']32 33 elif solutiontype == 'GiaSolution':34 analyses=['GiaIvinsAnalysis']35 36 elif solutiontype == 'LoveSolution':37 analyses=['LoveAnalysis']38 39 elif solutiontype == 'TransientSolution':40 analyses=['StressbalanceAnalysis','StressbalanceVerticalAnalysis','StressbalanceSIAAnalysis','L2ProjectionBaseAnalysis','ThermalAnalysis','MeltingAnalysis','EnthalpyAnalysis','MasstransportAnalysis']41 42 elif solutiontype == 'HydrologySolution':43 analyses=['L2ProjectionBaseAnalysis','HydrologyShreveAnalysis','HydrologyDCInefficientAnalysis','HydrologyDCEfficientAnalysis']44 45 elif 'DamageEvolutionSolution':46 analyses=['DamageEvolutionAnalysis']47 48 else:49 raise TypeError("solution type: '%s' not supported yet!" % solutiontype)50 51 return analyses52 #}}}53 41 54 42 def ismodelselfconsistent(md): 55 56 43 """ 44 ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem. 57 45 58 59 60 46 Usage: 47 ismodelselfconsistent(md), 48 """ 61 49 62 63 md.private.isconsistent=True50 #initialize consistency as true 51 md.private.isconsistent = True 64 52 65 #Get solution and associated analyses 66 solution=md.private.solution 67 analyses=AnalysisConfiguration(solution) 53 #Get solution and associated analyses 54 solution = md.private.solution 55 analyses = AnalysisConfiguration(solution) 56 #Go through a model fields, check that it is a class, and call checkconsistency 57 #fields = vars(md) 58 #for field in fields.iterkeys(): 59 for field in md.properties(): 60 #Some properties do not need to be checked 61 if field in ['results', 'debug', 'radaroverlay']: 62 continue 68 63 69 #Go through a model fields, check that it is a class, and call checkconsistency 70 fields=vars(md) 71 # for field in fields.iterkeys(): 72 for field in md.properties(): 64 #Check that current field is an object 65 if not hasattr(getattr(md, field), 'checkconsistency'): 66 md.checkmessage("field '%s' is not an object." % field) 73 67 74 #Some properties do not need to be checked 75 if field in ['results','debug','radaroverlay']: 76 continue 68 #Check consistency of the object 69 exec("md.{}.checkconsistency(md, '{}', {})".format(field, solution, analyses)) 77 70 78 #Check that current field is an object 79 if not hasattr(getattr(md,field),'checkconsistency'): 80 md.checkmessage("field '%s' is not an object." % field) 81 82 #Check consistency of the object 83 exec("md.{}.checkconsistency(md,solution,analyses)".format(field)) 84 85 #error message if mode is not consistent 86 if not md.private.isconsistent: 87 raise RuntimeError('Model not consistent, see messages above.') 88 71 #error message if mode is not consistent 72 if not md.private.isconsistent: 73 raise RuntimeError('Model not consistent, see messages above.')
Note:
See TracChangeset
for help on using the changeset viewer.