[13980] | 1 | Index: ../trunk-jpl/test/NightlyRun/test3005.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/test/NightlyRun/test3005.py (revision 13899)
|
---|
| 4 | +++ ../trunk-jpl/test/NightlyRun/test3005.py (revision 13900)
|
---|
| 5 | @@ -1,24 +1,21 @@
|
---|
| 6 | -from MatlabFuncs import *
|
---|
| 7 | from model import *
|
---|
| 8 | -from EnumDefinitions import *
|
---|
| 9 | -import numpy
|
---|
| 10 | from triangle import *
|
---|
| 11 | from setmask import *
|
---|
| 12 | from parameterize import *
|
---|
| 13 | from setflowequation import *
|
---|
| 14 | +from EnumDefinitions import *
|
---|
| 15 | from solve import *
|
---|
| 16 | +from MatlabFuncs import *
|
---|
| 17 |
|
---|
| 18 | -md=triangle(model(),'../Exp/Square.exp',150000)
|
---|
| 19 | +md=triangle(model(),'../Exp/Square.exp',150000.)
|
---|
| 20 | md=setmask(md,'all','')
|
---|
| 21 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 22 | md=setflowequation(md,'macayeal','all')
|
---|
| 23 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 24 | -md.autodiff.isautodiff=true
|
---|
| 25 | +md.autodiff.isautodiff=True
|
---|
| 26 | md=solve(md,PrognosticSolutionEnum())
|
---|
| 27 |
|
---|
| 28 | -
|
---|
| 29 | -# Fields and tolerances to track changes
|
---|
| 30 | -
|
---|
| 31 | +#Fields and tolerances to track changes
|
---|
| 32 | field_names =['Thickness']
|
---|
| 33 | field_tolerances=[1e-13]
|
---|
| 34 | field_values=[\
|
---|
| 35 | Index: ../trunk-jpl/test/NightlyRun/test3019.py
|
---|
| 36 | ===================================================================
|
---|
| 37 | --- ../trunk-jpl/test/NightlyRun/test3019.py (revision 0)
|
---|
| 38 | +++ ../trunk-jpl/test/NightlyRun/test3019.py (revision 13900)
|
---|
| 39 | @@ -0,0 +1,46 @@
|
---|
| 40 | +import numpy
|
---|
| 41 | +from model import *
|
---|
| 42 | +from triangle import *
|
---|
| 43 | +from setmask import *
|
---|
| 44 | +from parameterize import *
|
---|
| 45 | +from setflowequation import *
|
---|
| 46 | +from independent import *
|
---|
| 47 | +from dependent import *
|
---|
| 48 | +from EnumDefinitions import *
|
---|
| 49 | +from solve import *
|
---|
| 50 | +from MatlabFuncs import *
|
---|
| 51 | +
|
---|
| 52 | +#test reverse scalar vs forward vectorial drivers in ADOLC, using the test3009 setup, equivalent to test109 setup.
|
---|
| 53 | +md=triangle(model(),'../Exp/Square.exp',100000.)
|
---|
| 54 | +md=setmask(md,'all','')
|
---|
| 55 | +md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 56 | +md=setflowequation(md,'macayeal','all')
|
---|
| 57 | +md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 58 | +
|
---|
| 59 | +md.autodiff.isautodiff=True
|
---|
| 60 | +md.verbose.autodiff=True
|
---|
| 61 | +
|
---|
| 62 | +#first run scalar reverse mode:
|
---|
| 63 | +md.autodiff.independents=[independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices)]
|
---|
| 64 | +md.autodiff.dependents=[dependent('name','MaxVel','type','scalar','fos_reverse_index',1)]
|
---|
| 65 | +md.autodiff.driver='fos_reverse'
|
---|
| 66 | +
|
---|
| 67 | +md=solve(md,TransientSolutionEnum())
|
---|
| 68 | +
|
---|
| 69 | +#recover jacobian:
|
---|
| 70 | +jac_reverse=md.results['TransientSolution'][1]['AutodiffJacobian']
|
---|
| 71 | +
|
---|
| 72 | +#now run vectorial forward mode
|
---|
| 73 | +md.autodiff.independents=[independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fov_forward_indices',numpy.arange(0,md.mesh.numberofvertices))]
|
---|
| 74 | +md.autodiff.dependents=[dependent('name','MaxVel','type','scalar')]
|
---|
| 75 | +md.autodiff.driver='fov_forward'
|
---|
| 76 | +
|
---|
| 77 | +md=solve(md,TransientSolutionEnum())
|
---|
| 78 | +
|
---|
| 79 | +#recover jacobian:
|
---|
| 80 | +jac_forward=md.results['TransientSolution'][1]['AutodiffJacobian']
|
---|
| 81 | +
|
---|
| 82 | +#Fields and tolerances to track changes
|
---|
| 83 | +field_names =['Jac Forward','Jac Reverse','Jac Forward - Reverse']
|
---|
| 84 | +field_tolerances=[1e-13,1e-13,1e-13]
|
---|
| 85 | +field_values=[jac_forward,jac_reverse,jac_forward-jac_reverse]
|
---|
| 86 | Index: ../trunk-jpl/test/NightlyRun/test3019.m
|
---|
| 87 | ===================================================================
|
---|
| 88 | --- ../trunk-jpl/test/NightlyRun/test3019.m (revision 13899)
|
---|
| 89 | +++ ../trunk-jpl/test/NightlyRun/test3019.m (revision 13900)
|
---|
| 90 | @@ -18,7 +18,6 @@
|
---|
| 91 | %recover jacobian:
|
---|
| 92 | jac_reverse=md.results.TransientSolution(1).AutodiffJacobian;
|
---|
| 93 |
|
---|
| 94 | -
|
---|
| 95 | %now run vectorial forward mode
|
---|
| 96 | md.autodiff.independents={independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fov_forward_indices',(1:md.mesh.numberofvertices)')};
|
---|
| 97 | md.autodiff.dependents={dependent('name','MaxVel','type','scalar')};
|
---|
| 98 | @@ -29,7 +28,6 @@
|
---|
| 99 | %recover jacobian:
|
---|
| 100 | jac_forward=md.results.TransientSolution(1).AutodiffJacobian;
|
---|
| 101 |
|
---|
| 102 | -
|
---|
| 103 | %Fields and tolerances to track changes
|
---|
| 104 | field_names ={'Jac Forward','Jac Reverse','Jac Forward - Reverse'};
|
---|
| 105 | field_tolerances={1e-13,1e-13,1e-13};
|
---|
| 106 | Index: ../trunk-jpl/test/NightlyRun/test3020.m
|
---|
| 107 | ===================================================================
|
---|
| 108 | --- ../trunk-jpl/test/NightlyRun/test3020.m (revision 13899)
|
---|
| 109 | +++ ../trunk-jpl/test/NightlyRun/test3020.m (revision 13900)
|
---|
| 110 | @@ -7,9 +7,9 @@
|
---|
| 111 | md=parameterize(md,'../Par/SquareShelfConstrained.par');
|
---|
| 112 | md=setflowequation(md,'macayeal','all');
|
---|
| 113 | md.cluster=generic('name',oshostname(),'np',3);
|
---|
| 114 | -md.transient.requested_outputs=[IceVolumeEnum();MaxVelEnum];
|
---|
| 115 | +md.transient.requested_outputs=[IceVolumeEnum();MaxVelEnum()];
|
---|
| 116 | md.verbose=verbose('autodiff',true);
|
---|
| 117 | -md.diagnostic.restol=.000001;
|
---|
| 118 | +md.diagnostic.restol=0.000001;
|
---|
| 119 |
|
---|
| 120 | %setup autodiff parameters
|
---|
| 121 | index=1; %this is the scalar component we are checking against
|
---|
| 122 | @@ -23,11 +23,11 @@
|
---|
| 123 | };
|
---|
| 124 | md.autodiff.driver='fos_forward';
|
---|
| 125 |
|
---|
| 126 | -%parameters for the step-wise devivative
|
---|
| 127 | -delta=.00001;
|
---|
| 128 | +%parameters for the step-wise derivative
|
---|
| 129 | +delta=0.00001;
|
---|
| 130 | h1=md.geometry.thickness(index);
|
---|
| 131 | -h0=h1*(1-delta);
|
---|
| 132 | -h2=h1*(1+delta);
|
---|
| 133 | +h0=h1*(1.-delta);
|
---|
| 134 | +h2=h1*(1.+delta);
|
---|
| 135 | deltaH=(h2-h0);
|
---|
| 136 |
|
---|
| 137 | %save model:
|
---|
| 138 | @@ -62,7 +62,6 @@
|
---|
| 139 | dVdh_an=(V2-V0)/deltaH;
|
---|
| 140 | dMaxVdh_an=(MaxV2-MaxV0)/deltaH;
|
---|
| 141 |
|
---|
| 142 | -
|
---|
| 143 | %evaluate derivative using ADOLC
|
---|
| 144 | md=md2;
|
---|
| 145 | md.autodiff.isautodiff=true;
|
---|
| 146 | @@ -79,7 +78,6 @@
|
---|
| 147 | disp(sprintf('dV/dh: analytical: %16.16g\n using adolc: %16.16g\n',dVdh_an,dVdh_ad));
|
---|
| 148 | disp(sprintf('dMaxV/dh: analytical: %16.16g\n using adolc: %16.16g\n',dMaxVdh_an,dMaxVdh_ad));
|
---|
| 149 |
|
---|
| 150 | -
|
---|
| 151 | %Fields and tolerances to track changes
|
---|
| 152 | field_names ={'dV/dh-dV/dh0','dMaxV/dh-dMaxV/dh0'};
|
---|
| 153 | field_tolerances={1e-13,1e-13};
|
---|
| 154 | Index: ../trunk-jpl/test/NightlyRun/test3006.py
|
---|
| 155 | ===================================================================
|
---|
| 156 | --- ../trunk-jpl/test/NightlyRun/test3006.py (revision 13899)
|
---|
| 157 | +++ ../trunk-jpl/test/NightlyRun/test3006.py (revision 13900)
|
---|
| 158 | @@ -1,15 +1,14 @@
|
---|
| 159 | -from MatlabFuncs import *
|
---|
| 160 | from model import *
|
---|
| 161 | -from EnumDefinitions import *
|
---|
| 162 | -import numpy
|
---|
| 163 | from triangle import *
|
---|
| 164 | from meshconvert import *
|
---|
| 165 | from setmask import *
|
---|
| 166 | from parameterize import *
|
---|
| 167 | from setflowequation import *
|
---|
| 168 | +from EnumDefinitions import *
|
---|
| 169 | from solve import *
|
---|
| 170 | +from MatlabFuncs import *
|
---|
| 171 |
|
---|
| 172 | -md=triangle(model(),'../Exp/Square.exp',150000)
|
---|
| 173 | +md=triangle(model(),'../Exp/Square.exp',150000.)
|
---|
| 174 | md=meshconvert(md)
|
---|
| 175 | md=setmask(md,'all','')
|
---|
| 176 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 177 | @@ -17,12 +16,10 @@
|
---|
| 178 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 179 | md.prognostic.stabilization=3
|
---|
| 180 | md.prognostic.spcthickness=md.geometry.thickness
|
---|
| 181 | -md.autodiff.isautodiff=true
|
---|
| 182 | +md.autodiff.isautodiff=True
|
---|
| 183 | md=solve(md,PrognosticSolutionEnum())
|
---|
| 184 |
|
---|
| 185 | -
|
---|
| 186 | -# Fields and tolerances to track changes
|
---|
| 187 | -
|
---|
| 188 | +#Fields and tolerances to track changes
|
---|
| 189 | field_names =['Thickness']
|
---|
| 190 | field_tolerances=[1e-13]
|
---|
| 191 | field_values=[\
|
---|
| 192 | Index: ../trunk-jpl/test/NightlyRun/test3001.py
|
---|
| 193 | ===================================================================
|
---|
| 194 | --- ../trunk-jpl/test/NightlyRun/test3001.py (revision 13899)
|
---|
| 195 | +++ ../trunk-jpl/test/NightlyRun/test3001.py (revision 13900)
|
---|
| 196 | @@ -1,25 +1,22 @@
|
---|
| 197 | -from MatlabFuncs import *
|
---|
| 198 | from model import *
|
---|
| 199 | -from EnumDefinitions import *
|
---|
| 200 | -import numpy
|
---|
| 201 | from triangle import *
|
---|
| 202 | from setmask import *
|
---|
| 203 | from parameterize import *
|
---|
| 204 | from setflowequation import *
|
---|
| 205 | +from EnumDefinitions import *
|
---|
| 206 | from solve import *
|
---|
| 207 | +from MatlabFuncs import *
|
---|
| 208 |
|
---|
| 209 | -md=triangle(model(),'../Exp/Square.exp',50000)
|
---|
| 210 | +md=triangle(model(),'../Exp/Square.exp',50000.)
|
---|
| 211 | md=setmask(md,'all','')
|
---|
| 212 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 213 | md=setflowequation(md,'macayeal','all')
|
---|
| 214 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 215 | md.diagnostic.requested_outputs=StressTensorEnum()
|
---|
| 216 | -md.autodiff.isautodiff=true
|
---|
| 217 | +md.autodiff.isautodiff=True
|
---|
| 218 | md=solve(md,DiagnosticSolutionEnum())
|
---|
| 219 |
|
---|
| 220 | -
|
---|
| 221 | -# Fields and tolerances to track changes
|
---|
| 222 | -
|
---|
| 223 | +#Fields and tolerances to track changes
|
---|
| 224 | field_names =['Vx','Vy','Vel','Pressure',\
|
---|
| 225 | 'StressTensorxx','StressTensoryy','StressTensorxy']
|
---|
| 226 | field_tolerances=[1e-13,1e-13,1e-13,1e-13,\
|
---|
| 227 | Index: ../trunk-jpl/test/NightlyRun/test3015.py
|
---|
| 228 | ===================================================================
|
---|
| 229 | --- ../trunk-jpl/test/NightlyRun/test3015.py (revision 0)
|
---|
| 230 | +++ ../trunk-jpl/test/NightlyRun/test3015.py (revision 13900)
|
---|
| 231 | @@ -0,0 +1,91 @@
|
---|
| 232 | +import numpy
|
---|
| 233 | +import copy
|
---|
| 234 | +from model import *
|
---|
| 235 | +from triangle import *
|
---|
| 236 | +from setmask import *
|
---|
| 237 | +from parameterize import *
|
---|
| 238 | +from setflowequation import *
|
---|
| 239 | +from independent import *
|
---|
| 240 | +from dependent import *
|
---|
| 241 | +from SetIceShelfBC import *
|
---|
| 242 | +from EnumDefinitions import *
|
---|
| 243 | +from solve import *
|
---|
| 244 | +from MatlabFuncs import *
|
---|
| 245 | +
|
---|
| 246 | +#This test runs test3005 with autodiff on, and checks that
|
---|
| 247 | +#the value of the scalar forward difference match a step-wise differential
|
---|
| 248 | +
|
---|
| 249 | +#First configure
|
---|
| 250 | +md=triangle(model(),'../Exp/Square.exp',50000.)
|
---|
| 251 | +md=setmask(md,'all','')
|
---|
| 252 | +md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 253 | +md=setflowequation(md,'macayeal','all')
|
---|
| 254 | +md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 255 | +md.prognostic.requested_outputs=IceVolumeEnum()
|
---|
| 256 | +md.verbose=verbose('autodiff',True)
|
---|
| 257 | +
|
---|
| 258 | +#setup autodiff parameters
|
---|
| 259 | +index=0 #this is the scalar component we are checking against
|
---|
| 260 | +md.autodiff.independents=[\
|
---|
| 261 | + independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index)
|
---|
| 262 | + ]
|
---|
| 263 | +
|
---|
| 264 | +md.autodiff.dependents=[\
|
---|
| 265 | + dependent('name','IceVolume','type','scalar')\
|
---|
| 266 | + ]
|
---|
| 267 | +md.autodiff.driver='fos_forward'
|
---|
| 268 | +
|
---|
| 269 | +#parameters for the step-wise derivative
|
---|
| 270 | +delta=0.001
|
---|
| 271 | +h1=md.geometry.thickness[index]
|
---|
| 272 | +h0=h1*(1.-delta)
|
---|
| 273 | +h2=h1*(1.+delta)
|
---|
| 274 | +deltaH=(h2-h0)
|
---|
| 275 | +
|
---|
| 276 | +#save model
|
---|
| 277 | +md2=copy.deepcopy(md)
|
---|
| 278 | +
|
---|
| 279 | +#evaluate derivative by forward and backward stepping
|
---|
| 280 | +#forward
|
---|
| 281 | +md=copy.deepcopy(md2)
|
---|
| 282 | +md.autodiff.isautodiff=False
|
---|
| 283 | +md.geometry.thickness[index]=h0
|
---|
| 284 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 285 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 286 | +md=SetIceShelfBC(md)
|
---|
| 287 | +
|
---|
| 288 | +md=solve(md,PrognosticSolutionEnum())
|
---|
| 289 | +V0=md.results['PrognosticSolution'][1]['IceVolume']
|
---|
| 290 | +
|
---|
| 291 | +#backward
|
---|
| 292 | +md=copy.deepcopy(md2)
|
---|
| 293 | +md.autodiff.isautodiff=False
|
---|
| 294 | +md.geometry.thickness[index]=h2
|
---|
| 295 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 296 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 297 | +md=SetIceShelfBC(md)
|
---|
| 298 | +
|
---|
| 299 | +md=solve(md,PrognosticSolutionEnum())
|
---|
| 300 | +V2=md.results['PrognosticSolution'][1]['IceVolume']
|
---|
| 301 | +
|
---|
| 302 | +#compute resulting derivative
|
---|
| 303 | +dVdh_an=(V2-V0)/deltaH
|
---|
| 304 | +
|
---|
| 305 | +#evaluate derivative using ADOLC
|
---|
| 306 | +md=md2
|
---|
| 307 | +md.autodiff.isautodiff=True
|
---|
| 308 | +md.geometry.thickness[index]=h1
|
---|
| 309 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 310 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 311 | +md=SetIceShelfBC(md)
|
---|
| 312 | +
|
---|
| 313 | +md=solve(md,PrognosticSolutionEnum())
|
---|
| 314 | +#retrieve directly
|
---|
| 315 | +dVdh_ad=md.results['PrognosticSolution'][1]['AutodiffJacobian']
|
---|
| 316 | +
|
---|
| 317 | +print "dV/dh: analytical: #16.16g\n using adolc: #16.16g\n" % (dVdh_an,dVdh_ad)
|
---|
| 318 | +
|
---|
| 319 | +#Fields and tolerances to track changes
|
---|
| 320 | +field_names =['dV/dh-dV/dh0']
|
---|
| 321 | +field_tolerances=[1e-13]
|
---|
| 322 | +field_values=[dVdh_ad-dVdh_an]
|
---|
| 323 | Index: ../trunk-jpl/test/NightlyRun/test3010.py
|
---|
| 324 | ===================================================================
|
---|
| 325 | --- ../trunk-jpl/test/NightlyRun/test3010.py (revision 13899)
|
---|
| 326 | +++ ../trunk-jpl/test/NightlyRun/test3010.py (revision 13900)
|
---|
| 327 | @@ -1,27 +1,23 @@
|
---|
| 328 | -from MatlabFuncs import *
|
---|
| 329 | from model import *
|
---|
| 330 | -from EnumDefinitions import *
|
---|
| 331 | -import numpy
|
---|
| 332 | from triangle import *
|
---|
| 333 | from setmask import *
|
---|
| 334 | from parameterize import *
|
---|
| 335 | from setflowequation import *
|
---|
| 336 | +from EnumDefinitions import *
|
---|
| 337 | from solve import *
|
---|
| 338 | +from MatlabFuncs import *
|
---|
| 339 |
|
---|
| 340 | -md=triangle(model(),'../Exp/Square.exp',150000)
|
---|
| 341 | +md=triangle(model(),'../Exp/Square.exp',150000.)
|
---|
| 342 | md=setmask(md,'all','')
|
---|
| 343 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 344 | md=setflowequation(md,'macayeal','all')
|
---|
| 345 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 346 | md.transient.requested_outputs=IceVolumeEnum()
|
---|
| 347 |
|
---|
| 348 | -
|
---|
| 349 | -md.autodiff.isautodiff=true
|
---|
| 350 | +md.autodiff.isautodiff=True
|
---|
| 351 | md=solve(md,TransientSolutionEnum())
|
---|
| 352 |
|
---|
| 353 | -
|
---|
| 354 | -# Fields and tolerances to track changes
|
---|
| 355 | -
|
---|
| 356 | +#Fields and tolerances to track changes
|
---|
| 357 | field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Volume1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Volume2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Volume3']
|
---|
| 358 | field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
|
---|
| 359 | 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
|
---|
| 360 | Index: ../trunk-jpl/test/NightlyRun/test3007.py
|
---|
| 361 | ===================================================================
|
---|
| 362 | --- ../trunk-jpl/test/NightlyRun/test3007.py (revision 13899)
|
---|
| 363 | +++ ../trunk-jpl/test/NightlyRun/test3007.py (revision 13900)
|
---|
| 364 | @@ -1,25 +1,22 @@
|
---|
| 365 | -from MatlabFuncs import *
|
---|
| 366 | from model import *
|
---|
| 367 | -from EnumDefinitions import *
|
---|
| 368 | -import numpy
|
---|
| 369 | from triangle import *
|
---|
| 370 | from setmask import *
|
---|
| 371 | from parameterize import *
|
---|
| 372 | from setflowequation import *
|
---|
| 373 | +from EnumDefinitions import *
|
---|
| 374 | from solve import *
|
---|
| 375 | +from MatlabFuncs import *
|
---|
| 376 |
|
---|
| 377 | -md=triangle(model(),'../Exp/Square.exp',150000)
|
---|
| 378 | +md=triangle(model(),'../Exp/Square.exp',150000.)
|
---|
| 379 | md=setmask(md,'all','')
|
---|
| 380 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 381 | md=setflowequation(md,'macayeal','all')
|
---|
| 382 | md.extrude(5,3.)
|
---|
| 383 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 384 | -md.autodiff.isautodiff=true
|
---|
| 385 | +md.autodiff.isautodiff=True
|
---|
| 386 | md=solve(md,PrognosticSolutionEnum())
|
---|
| 387 |
|
---|
| 388 | -
|
---|
| 389 | -# Fields and tolerances to track changes
|
---|
| 390 | -
|
---|
| 391 | +#Fields and tolerances to track changes
|
---|
| 392 | field_names =['Thickness']
|
---|
| 393 | field_tolerances=[1e-13]
|
---|
| 394 | field_values=[\
|
---|
| 395 | Index: ../trunk-jpl/test/NightlyRun/test3002.py
|
---|
| 396 | ===================================================================
|
---|
| 397 | --- ../trunk-jpl/test/NightlyRun/test3002.py (revision 13899)
|
---|
| 398 | +++ ../trunk-jpl/test/NightlyRun/test3002.py (revision 13900)
|
---|
| 399 | @@ -1,25 +1,22 @@
|
---|
| 400 | -from MatlabFuncs import *
|
---|
| 401 | from model import *
|
---|
| 402 | -from EnumDefinitions import *
|
---|
| 403 | -import numpy
|
---|
| 404 | from triangle import *
|
---|
| 405 | from setmask import *
|
---|
| 406 | from parameterize import *
|
---|
| 407 | from setflowequation import *
|
---|
| 408 | +from EnumDefinitions import *
|
---|
| 409 | from solve import *
|
---|
| 410 | +from MatlabFuncs import *
|
---|
| 411 |
|
---|
| 412 | -md=triangle(model(),'../Exp/Square.exp',180000)
|
---|
| 413 | +md=triangle(model(),'../Exp/Square.exp',180000.)
|
---|
| 414 | md=setmask(md,'all','')
|
---|
| 415 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 416 | md.extrude(3,2.)
|
---|
| 417 | md=setflowequation(md,'macayeal','all')
|
---|
| 418 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 419 | -md.autodiff.isautodiff=true
|
---|
| 420 | +md.autodiff.isautodiff=True
|
---|
| 421 | md=solve(md,DiagnosticSolutionEnum())
|
---|
| 422 |
|
---|
| 423 | -
|
---|
| 424 | -# Fields and tolerances to track changes
|
---|
| 425 | -
|
---|
| 426 | +#Fields and tolerances to track changes
|
---|
| 427 | field_names =['Vx','Vy','Vz','Vel','Pressure']
|
---|
| 428 | field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13]
|
---|
| 429 | field_values=[\
|
---|
| 430 | Index: ../trunk-jpl/test/NightlyRun/test3020.py
|
---|
| 431 | ===================================================================
|
---|
| 432 | --- ../trunk-jpl/test/NightlyRun/test3020.py (revision 0)
|
---|
| 433 | +++ ../trunk-jpl/test/NightlyRun/test3020.py (revision 13900)
|
---|
| 434 | @@ -0,0 +1,98 @@
|
---|
| 435 | +import numpy
|
---|
| 436 | +import copy
|
---|
| 437 | +from model import *
|
---|
| 438 | +from triangle import *
|
---|
| 439 | +from setmask import *
|
---|
| 440 | +from parameterize import *
|
---|
| 441 | +from setflowequation import *
|
---|
| 442 | +from independent import *
|
---|
| 443 | +from dependent import *
|
---|
| 444 | +from SetIceShelfBC import *
|
---|
| 445 | +from EnumDefinitions import *
|
---|
| 446 | +from solve import *
|
---|
| 447 | +from MatlabFuncs import *
|
---|
| 448 | +
|
---|
| 449 | +#This test runs test3020 with autodiff on, and checks that
|
---|
| 450 | +#the value of the scalar forward difference match a step-wise differential
|
---|
| 451 | +
|
---|
| 452 | +#First configure
|
---|
| 453 | +md=triangle(model(),'../Exp/Square.exp',150000.)
|
---|
| 454 | +md=setmask(md,'all','')
|
---|
| 455 | +md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 456 | +md=setflowequation(md,'macayeal','all')
|
---|
| 457 | +md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 458 | +md.transient.requested_outputs=[IceVolumeEnum(),MaxVelEnum()]
|
---|
| 459 | +md.verbose=verbose('autodiff',True)
|
---|
| 460 | +md.diagnostic.restol=0.000001
|
---|
| 461 | +
|
---|
| 462 | +#setup autodiff parameters
|
---|
| 463 | +index=0 #this is the scalar component we are checking against
|
---|
| 464 | +md.autodiff.independents=[\
|
---|
| 465 | + independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index)
|
---|
| 466 | + ]
|
---|
| 467 | +
|
---|
| 468 | +md.autodiff.dependents=[\
|
---|
| 469 | + dependent('name','IceVolume','type','scalar'),\
|
---|
| 470 | + dependent('name','MaxVel','type','scalar')\
|
---|
| 471 | + ]
|
---|
| 472 | +md.autodiff.driver='fos_forward'
|
---|
| 473 | +
|
---|
| 474 | +#parameters for the step-wise derivative
|
---|
| 475 | +delta=0.00001
|
---|
| 476 | +h1=md.geometry.thickness[index]
|
---|
| 477 | +h0=h1*(1.-delta)
|
---|
| 478 | +h2=h1*(1.+delta)
|
---|
| 479 | +deltaH=(h2-h0)
|
---|
| 480 | +
|
---|
| 481 | +#save model:
|
---|
| 482 | +md2=copy.deepcopy(md)
|
---|
| 483 | +
|
---|
| 484 | +#evaluate derivative by forward and backward stepping
|
---|
| 485 | +#forward
|
---|
| 486 | +md=copy.deepcopy(md2)
|
---|
| 487 | +md.autodiff.isautodiff=False
|
---|
| 488 | +md.geometry.thickness[index]=h0
|
---|
| 489 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 490 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 491 | +md=SetIceShelfBC(md)
|
---|
| 492 | +
|
---|
| 493 | +md=solve(md,TransientSolutionEnum())
|
---|
| 494 | +V0=md.results['TransientSolution'][3]['IceVolume']
|
---|
| 495 | +MaxV0=md.results['TransientSolution'][3]['MaxVel']
|
---|
| 496 | +
|
---|
| 497 | +#backward
|
---|
| 498 | +md=copy.deepcopy(md2)
|
---|
| 499 | +md.autodiff.isautodiff=False
|
---|
| 500 | +md.geometry.thickness[index]=h2
|
---|
| 501 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 502 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 503 | +md=SetIceShelfBC(md)
|
---|
| 504 | +
|
---|
| 505 | +md=solve(md,TransientSolutionEnum())
|
---|
| 506 | +V2=md.results['TransientSolution'][3]['IceVolume']
|
---|
| 507 | +MaxV2=md.results['TransientSolution'][3]['MaxVel']
|
---|
| 508 | +
|
---|
| 509 | +#compute resulting derivative
|
---|
| 510 | +dVdh_an=(V2-V0)/deltaH
|
---|
| 511 | +dMaxVdh_an=(MaxV2-MaxV0)/deltaH
|
---|
| 512 | +
|
---|
| 513 | +#evaluate derivative using ADOLC
|
---|
| 514 | +md=copy.deepcopy(md2)
|
---|
| 515 | +md.autodiff.isautodiff=True
|
---|
| 516 | +md.geometry.thickness[index]=h1
|
---|
| 517 | +md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
|
---|
| 518 | +md.geometry.surface=md.geometry.bed+md.geometry.thickness
|
---|
| 519 | +md=SetIceShelfBC(md)
|
---|
| 520 | +
|
---|
| 521 | +md=solve(md,TransientSolutionEnum())
|
---|
| 522 | +#retrieve directly
|
---|
| 523 | +dVdh_ad=md.results['TransientSolution'][1]['AutodiffJacobian'][0]
|
---|
| 524 | +dMaxVdh_ad=md.results['TransientSolution'][1]['AutodiffJacobian'][1]
|
---|
| 525 | +
|
---|
| 526 | +print "dV/dh: analytical: %16.16g\n using adolc: %16.16g\n" % (dVdh_an,dVdh_ad)
|
---|
| 527 | +print "dMaxV/dh: analytical: %16.16g\n using adolc: %16.16g\n" % (dMaxVdh_an,dMaxVdh_ad)
|
---|
| 528 | +
|
---|
| 529 | +#Fields and tolerances to track changes
|
---|
| 530 | +field_names =['dV/dh-dV/dh0','dMaxV/dh-dMaxV/dh0']
|
---|
| 531 | +field_tolerances=[1e-13,1e-13]
|
---|
| 532 | +field_values=[dVdh_ad-dVdh_an,dMaxVdh_an-dMaxVdh_ad]
|
---|
| 533 | Index: ../trunk-jpl/test/NightlyRun/test3008.py
|
---|
| 534 | ===================================================================
|
---|
| 535 | --- ../trunk-jpl/test/NightlyRun/test3008.py (revision 13899)
|
---|
| 536 | +++ ../trunk-jpl/test/NightlyRun/test3008.py (revision 13900)
|
---|
| 537 | @@ -1,26 +1,23 @@
|
---|
| 538 | -from MatlabFuncs import *
|
---|
| 539 | from model import *
|
---|
| 540 | -from EnumDefinitions import *
|
---|
| 541 | -import numpy
|
---|
| 542 | from triangle import *
|
---|
| 543 | from setmask import *
|
---|
| 544 | from parameterize import *
|
---|
| 545 | from setflowequation import *
|
---|
| 546 | +from EnumDefinitions import *
|
---|
| 547 | from solve import *
|
---|
| 548 | +from MatlabFuncs import *
|
---|
| 549 |
|
---|
| 550 | -md=triangle(model(),'../Exp/Square.exp',180000)
|
---|
| 551 | +md=triangle(model(),'../Exp/Square.exp',180000.)
|
---|
| 552 | md=setmask(md,'all','')
|
---|
| 553 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 554 | md.extrude(3,1.)
|
---|
| 555 | md=setflowequation(md,'macayeal','all')
|
---|
| 556 | md.timestepping.time_step=0
|
---|
| 557 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 558 | -md.autodiff.isautodiff=true
|
---|
| 559 | +md.autodiff.isautodiff=True
|
---|
| 560 | md=solve(md,ThermalSolutionEnum())
|
---|
| 561 |
|
---|
| 562 | -
|
---|
| 563 | -# Fields and tolerances to track changes
|
---|
| 564 | -
|
---|
| 565 | +#Fields and tolerances to track changes
|
---|
| 566 | field_names =['Temperature','BasalforcingsMeltingRate']
|
---|
| 567 | field_tolerances=[1e-13,1e-13]
|
---|
| 568 | field_values=[\
|
---|
| 569 | Index: ../trunk-jpl/test/NightlyRun/test3015.m
|
---|
| 570 | ===================================================================
|
---|
| 571 | --- ../trunk-jpl/test/NightlyRun/test3015.m (revision 13899)
|
---|
| 572 | +++ ../trunk-jpl/test/NightlyRun/test3015.m (revision 13900)
|
---|
| 573 | @@ -21,11 +21,11 @@
|
---|
| 574 | };
|
---|
| 575 | md.autodiff.driver='fos_forward';
|
---|
| 576 |
|
---|
| 577 | -%parameters for the step-wise devivative
|
---|
| 578 | -delta=.001;
|
---|
| 579 | +%parameters for the step-wise derivative
|
---|
| 580 | +delta=0.001;
|
---|
| 581 | h1=md.geometry.thickness(index);
|
---|
| 582 | -h0=h1*(1-delta);
|
---|
| 583 | -h2=h1*(1+delta);
|
---|
| 584 | +h0=h1*(1.-delta);
|
---|
| 585 | +h2=h1*(1.+delta);
|
---|
| 586 | deltaH=(h2-h0);
|
---|
| 587 |
|
---|
| 588 | %save model:
|
---|
| 589 | Index: ../trunk-jpl/test/NightlyRun/test3003.py
|
---|
| 590 | ===================================================================
|
---|
| 591 | --- ../trunk-jpl/test/NightlyRun/test3003.py (revision 13899)
|
---|
| 592 | +++ ../trunk-jpl/test/NightlyRun/test3003.py (revision 13900)
|
---|
| 593 | @@ -1,26 +1,23 @@
|
---|
| 594 | -from MatlabFuncs import *
|
---|
| 595 | from model import *
|
---|
| 596 | -from EnumDefinitions import *
|
---|
| 597 | -import numpy
|
---|
| 598 | from triangle import *
|
---|
| 599 | from setmask import *
|
---|
| 600 | from parameterize import *
|
---|
| 601 | from setflowequation import *
|
---|
| 602 | +from EnumDefinitions import *
|
---|
| 603 | from solve import *
|
---|
| 604 | +from MatlabFuncs import *
|
---|
| 605 |
|
---|
| 606 | -md=triangle(model(),'../Exp/Square.exp',180000)
|
---|
| 607 | +md=triangle(model(),'../Exp/Square.exp',180000.)
|
---|
| 608 | md=setmask(md,'all','')
|
---|
| 609 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 610 | md.extrude(3,2.)
|
---|
| 611 | md=setflowequation(md,'pattyn','all')
|
---|
| 612 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 613 | md.diagnostic.requested_outputs=StressTensorEnum()
|
---|
| 614 | -md.autodiff.isautodiff=true
|
---|
| 615 | +md.autodiff.isautodiff=True
|
---|
| 616 | md=solve(md,DiagnosticSolutionEnum())
|
---|
| 617 |
|
---|
| 618 | -
|
---|
| 619 | -# Fields and tolerances to track changes
|
---|
| 620 | -
|
---|
| 621 | +#Fields and tolerances to track changes
|
---|
| 622 | field_names =['Vx','Vy','Vz','Vel','Pressure',\
|
---|
| 623 | 'StressTensorxx','StressTensoryy','StressTensorzz','StressTensorxy','StressTensorxz','StressTensoryz']
|
---|
| 624 | field_tolerances=[1e-09,1e-09,1e-09,1e-09,1e-09,\
|
---|
| 625 | Index: ../trunk-jpl/test/NightlyRun/test3009.py
|
---|
| 626 | ===================================================================
|
---|
| 627 | --- ../trunk-jpl/test/NightlyRun/test3009.py (revision 13899)
|
---|
| 628 | +++ ../trunk-jpl/test/NightlyRun/test3009.py (revision 13900)
|
---|
| 629 | @@ -1,14 +1,13 @@
|
---|
| 630 | -from MatlabFuncs import *
|
---|
| 631 | from model import *
|
---|
| 632 | -from EnumDefinitions import *
|
---|
| 633 | -import numpy
|
---|
| 634 | from triangle import *
|
---|
| 635 | from setmask import *
|
---|
| 636 | from parameterize import *
|
---|
| 637 | from setflowequation import *
|
---|
| 638 | +from EnumDefinitions import *
|
---|
| 639 | from solve import *
|
---|
| 640 | +from MatlabFuncs import *
|
---|
| 641 |
|
---|
| 642 | -md=triangle(model(),'../Exp/Square.exp',180000)
|
---|
| 643 | +md=triangle(model(),'../Exp/Square.exp',180000.)
|
---|
| 644 | md=setmask(md,'all','')
|
---|
| 645 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 646 | md.extrude(3,1.)
|
---|
| 647 | @@ -18,12 +17,10 @@
|
---|
| 648 | md.transient.isprognostic=0
|
---|
| 649 | md.transient.isthermal=1
|
---|
| 650 | md.transient.isgroundingline=0
|
---|
| 651 | -md.autodiff.isautodiff=true
|
---|
| 652 | +md.autodiff.isautodiff=True
|
---|
| 653 | md=solve(md,TransientSolutionEnum())
|
---|
| 654 |
|
---|
| 655 | -
|
---|
| 656 | -# Fields and tolerances to track changes
|
---|
| 657 | -
|
---|
| 658 | +#Fields and tolerances to track changes
|
---|
| 659 | field_names =['Temperature','BasalforcingsMeltingRate']
|
---|
| 660 | field_tolerances=[1e-13,1e-13]
|
---|
| 661 | field_values=[\
|
---|
| 662 | Index: ../trunk-jpl/test/NightlyRun/test3004.py
|
---|
| 663 | ===================================================================
|
---|
| 664 | --- ../trunk-jpl/test/NightlyRun/test3004.py (revision 13899)
|
---|
| 665 | +++ ../trunk-jpl/test/NightlyRun/test3004.py (revision 13900)
|
---|
| 666 | @@ -1,25 +1,22 @@
|
---|
| 667 | -from MatlabFuncs import *
|
---|
| 668 | from model import *
|
---|
| 669 | -from EnumDefinitions import *
|
---|
| 670 | -import numpy
|
---|
| 671 | from triangle import *
|
---|
| 672 | from setmask import *
|
---|
| 673 | from parameterize import *
|
---|
| 674 | from setflowequation import *
|
---|
| 675 | +from EnumDefinitions import *
|
---|
| 676 | from solve import *
|
---|
| 677 | +from MatlabFuncs import *
|
---|
| 678 |
|
---|
| 679 | -md=triangle(model(),'../Exp/Square.exp',180000)
|
---|
| 680 | +md=triangle(model(),'../Exp/Square.exp',180000.)
|
---|
| 681 | md=setmask(md,'all','')
|
---|
| 682 | md=parameterize(md,'../Par/SquareShelfConstrained.py')
|
---|
| 683 | md.extrude(3,2.)
|
---|
| 684 | md=setflowequation(md,'stokes','all')
|
---|
| 685 | md.cluster=generic('name',oshostname(),'np',3)
|
---|
| 686 | -md.autodiff.isautodiff=true
|
---|
| 687 | +md.autodiff.isautodiff=True
|
---|
| 688 | md=solve(md,DiagnosticSolutionEnum())
|
---|
| 689 |
|
---|
| 690 | -
|
---|
| 691 | -# Fields and tolerances to track changes
|
---|
| 692 | -
|
---|
| 693 | +#Fields and tolerances to track changes
|
---|
| 694 | field_names =['Vx','Vy','Vz','Vel','Pressure']
|
---|
| 695 | field_tolerances=[1e-08,1e-08,1e-07,1e-08,1e-08]
|
---|
| 696 | field_values=[\
|
---|