1 | def AnalysisConfiguration(solutiontype): #{{{
|
---|
2 | """
|
---|
3 | ANALYSISCONFIGURATION - return type of analyses, number of analyses
|
---|
4 |
|
---|
5 | Usage:
|
---|
6 | [analyses]=AnalysisConfiguration(solutiontype);
|
---|
7 | """
|
---|
8 |
|
---|
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']
|
---|
31 | elif solutiontype == 'HydrologySolution':
|
---|
32 | analyses=['L2ProjectionBaseAnalysis','HydrologyShreveAnalysis','HydrologyDCInefficientAnalysis','HydrologyDCEfficientAnalysis']
|
---|
33 | elif 'DamageEvolutionSolution':
|
---|
34 | analyses=['DamageEvolutionAnalysis']
|
---|
35 |
|
---|
36 | else:
|
---|
37 | raise TypeError("solution type: '%s' not supported yet!" % solutiontype)
|
---|
38 |
|
---|
39 | return analyses
|
---|
40 | #}}}
|
---|
41 |
|
---|
42 | def ismodelselfconsistent(md):
|
---|
43 | """
|
---|
44 | ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
|
---|
45 |
|
---|
46 | Usage:
|
---|
47 | ismodelselfconsistent(md),
|
---|
48 | """
|
---|
49 |
|
---|
50 | #initialize consistency as true
|
---|
51 | md.private.isconsistent=True
|
---|
52 |
|
---|
53 | #Get solution and associated analyses
|
---|
54 | solution=md.private.solution
|
---|
55 | analyses=AnalysisConfiguration(solution)
|
---|
56 |
|
---|
57 | #Go through a model fields, check that it is a class, and call checkconsistency
|
---|
58 | fields=vars(md)
|
---|
59 | # for field in fields.iterkeys():
|
---|
60 | for field in md.properties():
|
---|
61 |
|
---|
62 | #Some properties do not need to be checked
|
---|
63 | if field in ['results','debug','radaroverlay']:
|
---|
64 | continue
|
---|
65 |
|
---|
66 | #Check that current field is an object
|
---|
67 | if not hasattr(getattr(md,field),'checkconsistency'):
|
---|
68 | md.checkmessage("field '%s' is not an object." % field)
|
---|
69 |
|
---|
70 | #Check consistency of the object
|
---|
71 | exec("md.{}.checkconsistency(md,solution,analyses)".format(field))
|
---|
72 |
|
---|
73 | #error message if mode is not consistent
|
---|
74 | if not md.private.isconsistent:
|
---|
75 | raise RuntimeError('Model not consistent, see messages above.')
|
---|