~iceshelfcavity/fluidity/iceshelfcavity_backup

« back to all changes in this revision

Viewing changes to tests/iceshelf3D_p1p1/iceshelf3D_p1p1.xml

  • Committer: Satoshi Kimura
  • Date: 2011-09-08 12:49:43 UTC
  • Revision ID: skimura04@gmail.com-20110908124943-42en658oyp29b20v
Added test cases for three dimensional iceshelf for p1p1 and p1dgp2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8" ?>
 
2
<!DOCTYPE testproblem SYSTEM "regressiontest.dtd">
 
3
 
 
4
<testproblem>
 
5
  <name>iceshelf3D_p1p1</name>
 
6
  <owner userid="skimura"/>
 
7
  <tags>flml</tags>
 
8
  <problem_definition length="short" nprocs="1">
 
9
    <command_line>fluidity -v3 -l shelf3d_p1p1.flml</command_line>
 
10
  </problem_definition>
 
11
  <variables>
 
12
    <variable name="err_p1" language="python">   
 
13
from fluidity_tools import stat_parser
 
14
import vtktools
 
15
from numpy import mean, sum
 
16
 
 
17
 
 
18
def check_TS_budget(fname,TimeIndex):
 
19
    pick = TimeIndex
 
20
    fname_stat = fname+".stat"
 
21
    stat=stat_parser(fname_stat)
 
22
    time = stat["ElapsedTime"]["value"] 
 
23
    Tint = stat["fluid"]["Temperature"]["integral"]
 
24
    Sint = stat["fluid"]["Salinity"]["integral"]
 
25
    ####Fluxes
 
26
    HF_surfV = stat["fluid"]["Heat_flux"]["surface_integral%surfTvalue"]
 
27
    SF_surfV = stat["fluid"]["Salt_flux"]["surface_integral%surfSvalue"]
 
28
 
 
29
    dtime = time[pick]-time[pick-1]
 
30
    ## Scalar fluxes predicted from the output betwee time[pick] and time[pick-1]
 
31
    dT = (Tint[pick]-Tint[pick-1])/dtime
 
32
    dS = (Sint[pick]-Sint[pick-1])/dtime
 
33
    ## Scalar fluxes predicted from the boundary condition
 
34
    dT_bc = HF_surfV[pick]
 
35
    dS_bc = SF_surfV[pick]
 
36
    ## Calculate the relative error
 
37
    errT = abs(dT_bc-dT)/abs(dT)
 
38
    errS = abs(dS_bc-dS)/abs(dS)
 
39
    print "*************check_TS_budget*******************"
 
40
    print "fname: ", fname
 
41
    print "time[TimeIndex]: ", time[pick]
 
42
    print "dT,dT_bc: ", dT,dT_bc
 
43
    print "dS,dS_bc: ", dS,dS_bc
 
44
    print "****************************************"
 
45
    return errT,errS
 
46
 
 
47
fname = "shelf3d_p1p1"
 
48
TimeIndex=1
 
49
[errT_p1,errS_p1]=check_TS_budget(fname,TimeIndex)
 
50
err_p1 = max(errT_p1, errS_p1)    
 
51
<!--fname = "shelf3d_p1dgp2"-->
 
52
<!--[errT_p2,errS_p2]=check_TS_budget(fname,TimeIndex)-->
 
53
<!--[R2_p2,Tp2,Sp2] = Gade_line_file(fname,TimeIndex)-->
 
54
 
 
55
    </variable>
 
56
    <variable name="R2_p1" language="python"> 
 
57
from fluidity_tools import stat_parser
 
58
import vtktools
 
59
from numpy import mean, sum
 
60
 
 
61
def Gade_line_file(fname,TimeIndex):
 
62
    fname_a = fname+"_"+str(TimeIndex)+".vtu"
 
63
    datafile = vtktools.vtu(fname_a)
 
64
    T=datafile.GetScalarField("Temperature")
 
65
    S=datafile.GetScalarField("Salinity")
 
66
 
 
67
    ###Construct Gade line, need the first time
 
68
    T1=0.0
 
69
    S1=35.0
 
70
 
 
71
    S_gade=S
 
72
    c0=3974.0
 
73
    cI=2009.0
 
74
    L=3.35e5
 
75
    Li=L
 
76
    TI=-25
 
77
    a=-0.0573
 
78
    b=0.0832
 
79
    Cd = 1.5e-3
 
80
    Tf=a*S1+b
 
81
    dTdS1 = ((T1-Tf)+Li/c0+(cI/c0)*(Tf-TI)) /(S1-0)
 
82
    T_gade = dTdS1*(S_gade-S1) +T1
 
83
    #Compare T_gade and T_1
 
84
    #Calculate R2 = 
 
85
    T_bar = mean(T)
 
86
    SS_tot = sum((T-T_bar)**2)
 
87
    SS_err = sum((T_gade-T)**2)
 
88
    R2 = 1-(SS_err)/(SS_tot)
 
89
    ### 
 
90
    print "**************Gade_line_file*****************"
 
91
    print "fname: ", fname_a
 
92
    print "R2: ", R2
 
93
    
 
94
    return R2,T,S
 
95
fname = "shelf3d_p1p1"
 
96
TimeIndex=1  
 
97
[R2_p1,Tp1,Sp1] = Gade_line_file(fname,TimeIndex)
 
98
R2_p1 = R2_p1
 
99
      </variable>
 
100
  </variables>
 
101
  <pass_tests>
 
102
    <test name="Checking heat and salt budget." language="python">
 
103
assert err_p1 &lt; 1e-5
 
104
    </test>
 
105
    <test name="Checking Gade line. R2 is computed." language="python">
 
106
assert R2_p1 > 0.98
 
107
    </test>
 
108
  </pass_tests>
 
109
  <warn_tests>
 
110
  </warn_tests>
 
111
</testproblem>