1 | #Test Name: EISMINTRoundIceSheetStaticSIA
|
---|
2 | import numpy as np
|
---|
3 | from model import *
|
---|
4 | from socket import gethostname
|
---|
5 | from roundmesh import *
|
---|
6 | from setmask import *
|
---|
7 | from parameterize import *
|
---|
8 | from setflowequation import *
|
---|
9 | from solve import *
|
---|
10 |
|
---|
11 |
|
---|
12 | """
|
---|
13 | The aim of this program is to compare a model with an analytical solution given in SSA EISMINT : Lessons in Ice-Sheet Modeling.
|
---|
14 | """
|
---|
15 |
|
---|
16 | printingflag = False
|
---|
17 |
|
---|
18 | numlayers = 10
|
---|
19 | resolution = 30000.
|
---|
20 |
|
---|
21 | #To begin with the numerical model
|
---|
22 | md = model()
|
---|
23 | md = roundmesh(md, 750000., resolution)
|
---|
24 | md = setmask(md, '', '') #We can not test iceshelves nor ice rises with this analytical solution
|
---|
25 | md = parameterize(md, '../Par/RoundSheetStaticEISMINT.py')
|
---|
26 |
|
---|
27 | #Calculation of the analytical 2d velocity field
|
---|
28 | constant = 0.3
|
---|
29 | vx_obs = constant / 2. * md.mesh.x * (md.geometry.thickness)**- 1
|
---|
30 | vy_obs = constant / 2. * md.mesh.y * (md.geometry.thickness)**- 1
|
---|
31 | vel_obs = np.sqrt((md.inversion.vx_obs)**2 + (md.inversion.vy_obs)**2)
|
---|
32 |
|
---|
33 | #We extrude the model to have a 3d model
|
---|
34 | md.extrude(numlayers, 1.)
|
---|
35 | md = setflowequation(md, 'SIA', 'all')
|
---|
36 |
|
---|
37 | #Spc the nodes on the bed
|
---|
38 | pos = np.where(md.mesh.vertexonbase)
|
---|
39 | md.stressbalance.spcvx[pos] = 0.
|
---|
40 | md.stressbalance.spcvy[pos] = 0.
|
---|
41 | md.stressbalance.spcvz[pos] = 0.
|
---|
42 |
|
---|
43 | #Now we can solve the problem
|
---|
44 | md.cluster = generic('name', gethostname(), 'np', 8)
|
---|
45 | md = solve(md, 'Stressbalance')
|
---|
46 |
|
---|
47 | #Calculate the depth averaged velocity field (2d):
|
---|
48 | vx = md.results.StressbalanceSolution.Vx
|
---|
49 | vy = md.results.StressbalanceSolution.Vy
|
---|
50 | vel = np.zeros((md.mesh.numberofvertices2d))
|
---|
51 |
|
---|
52 | for i in range(0, md.mesh.numberofvertices2d):
|
---|
53 | node_vel = 0.
|
---|
54 | for j in range(0, md.mesh.numberoflayers - 1):
|
---|
55 | node_vel = node_vel + 1. / (2. * (md.mesh.numberoflayers - 1)) * (np.sqrt(vx[i + (j + 1) * md.mesh.numberofvertices2d, 0]**2 + vy[i + (j + 1) * md.mesh.numberofvertices2d, 0]**2) + np.sqrt(vx[i + j * md.mesh.numberofvertices2d, 0]**2 + vy[i + j * md.mesh.numberofvertices2d, 0]**2))
|
---|
56 | vel[i] = node_vel
|
---|
57 |
|
---|
58 | #Plot of the velocity from the exact and calculated solutions
|
---|
59 | #figure(1)
|
---|
60 | #set(gcf, 'Position', [1 1 1580 1150])
|
---|
61 | #subplot(2, 2, 1)
|
---|
62 | #p = patch('Faces', md.mesh.elements2d, 'Vertices', [md.mesh.x2d md.mesh.y2d], 'FaceVertexCData', ...
|
---|
63 | #vel, 'FaceColor', 'interp', 'EdgeColor', 'none')
|
---|
64 | #title('Modelled velocity', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
65 | #colorbar
|
---|
66 | #caxis([0 200])
|
---|
67 |
|
---|
68 | #subplot(2, 2, 2)
|
---|
69 | #p = patch('Faces', md.mesh.elements2d, 'Vertices', [md.mesh.x2d md.mesh.y2d], 'FaceVertexCData', ...
|
---|
70 | #vel_obs, 'FaceColor', 'interp', 'EdgeColor', 'none')
|
---|
71 | #title('Analytical velocity', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
72 | #colorbar
|
---|
73 | #caxis([0 200])
|
---|
74 |
|
---|
75 | #subplot(2, 2, 3)
|
---|
76 | #hold on
|
---|
77 | #plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2 + (md.mesh.y(1:md.mesh.numberofvertices2d)).^2), vel, 'r.')
|
---|
78 | #plot(sqrt((md.mesh.x2d).^2 + (md.mesh.y2d).^2), vel_obs, 'b.')
|
---|
79 | #title('Analytical vs calculated velocity', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
80 | #xlabel('distance to the center of the icesheet [m]', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
81 | #ylabel('velocity [m / yr]', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
82 | #legend('calculated velocity', 'exact velocity')
|
---|
83 | #axis([0 750000 0 200])
|
---|
84 | #hold off
|
---|
85 |
|
---|
86 | #subplot(2, 2, 4)
|
---|
87 | #p = patch('Faces', md.mesh.elements2d, 'Vertices', [md.mesh.x2d md.mesh.y2d], 'FaceVertexCData', ...
|
---|
88 | #abs(vel - vel_obs). / vel_obs * 100, 'FaceColor', 'interp', 'EdgeColor', 'none')
|
---|
89 | #title('Relative misfit [%]', 'FontSize', 14, 'FontWeight', 'bold')
|
---|
90 | #colorbar
|
---|
91 | #caxis([0 100])
|
---|
92 |
|
---|
93 | if printingflag:
|
---|
94 | pass
|
---|
95 | # set(gcf, 'Color', 'w')
|
---|
96 | # printmodel('SIAstatic', 'png', 'margin', 'on', 'marginsize', 25, 'frame', 'off', 'resolution', 0.7, 'hardcopy', 'off')
|
---|
97 | # system(['mv SIAstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet'])
|
---|
98 |
|
---|
99 | #Fields and tolerances to track changes
|
---|
100 | field_names = ['Vx', 'Vy', 'Vel']
|
---|
101 | field_tolerances = [1e-13, 1e-13, 1e-13]
|
---|
102 | field_values = [vx, vy, vel]
|
---|