Comments (4)
Hi Bryan! The code in that notebook to compute u_shear
isn't evaluating the basal velocity as such, but rather the projection of the velocity field onto the 1st-degree Legendre polynomial, which is orthogonal to the constant functions. So it is to be expected that the basal velocity (or the surface - basal difference) is not the same as this projection.
The code that you've written certainly ought to work to compute the basal velocity. If you want something that will make a Function defined on the base mesh instead of a grid of values, you can also do this by a clever weighted depth-average. Let me know if that's what you need and I'll send some more complete code for it.
from icepack.
Ah, thanks Daniel for clearing that up! The projection makes sense. Indeed, I think I could make use of a few examples of clever depth-average weighting. I was originally thinking of constructing delta functions centered at arbitrary depths, but I'm pretty sure I would've done that wrong!
from icepack.
I made a branch with some demonstrations in the hybrid XZ notebook here. The important part is right before the conclusion section. In case you don't want to go digging through all that, here's the code to calculate the basal and surface velocities and plot them:
import sympy
ξ = sympy.symbols("ξ", real=True)
legendre_polynomials = [sympy.legendre(n, 2 * ξ - 1) for n in range(3)]
basis_functions = [p / sympy.sqrt(sympy.integrate(p**2, (ξ, 0, 1))) for p in legendre_polynomials]
basal_values = [p.subs({ξ: 0}) for p in basis_functions]
surface_values = [p.subs({ξ: 1}) for p in basis_functions]
basal_polynomial = sum(w * p for w, p in zip(basal_values, basis_functions))
surface_polynomial = sum(w * p for w, p in zip(surface_values, basis_functions))
basal_weight = sympy.lambdify(ξ, basal_polynomial.simplify())(ζ)
surface_weight = sympy.lambdify(ξ, surface_polynomial.simplify())(ζ)
u_basal = icepack.depth_average(u, weight=basal_weight)
u_surface = icepack.depth_average(u, weight=surface_weight)
fig, axes = plt.subplots()
axes.set_title("Surface & basal velocities")
firedrake.plot(u_basal, edgecolor="tab:blue", label="basal", axes=axes)
firedrake.plot(u_surface, edgecolor="tab:red", label="surface", axes=axes)
axes.legend();
Does all the sympy + Legendre polynomial hackery here make sense? You mentioned constructing delta functions at arbitrary depths. This code is doing that by instead looking at the action of a delta function on something that we know has an expansion in Legendre polynomials. So it does what a delta function would do without having to actually form the delta function as such. In any case this should be probably either be in a tutorial or in icepack itself. The attached figure shows the result.
I am a little disturbed by the fact that you can evaluate things at negative values of the vertical coordinate -- arguably those should be giving a "point not in domain" error. That's more of a Firedrake issue than an icepack issue.
Closing this for now, feel free to reopen if anything else is unclear.
from icepack.
Many thanks Daniel, I think I understand now how the weights are interpreted with respect to a Legendre polynomial expansion. That's quite clever!
Yeah, I'm not too worried now about the out-of-domain evaluations. Perhaps firedrake is assuming that the user knows the vertical mesh is represented by a polynomial expansion and can thus technically be evaluated out of the domain. I'll just make sure never to do that.
from icepack.
Related Issues (20)
- No changes when running diagnostic_solve HOT 3
- Parallelism in icepack and Firedrake HOT 3
- flush needed to output "ICEPACK COMPLETE" on OSX gnu compiler HOT 1
- Negative rate factors with reasonable temperatures HOT 2
- Questions about the exact equation in the Synthetic ice stream (xy) case HOT 1
- Passing rate factor calculated from temperature back into 2D flow solver HOT 2
- Managing data interpolation onto extruded meshes HOT 3
- pip3 fails to install ROL HOT 5
- Unexpected differences with Hybrid model compared to Elmer/Ice with Cuffey and Paterson A HOT 8
- Zero regularization in 05-ice-shelf-inverse tutorial HOT 3
- Error with multi-parameter optimization
- more specific errors
- Error when running Lid Driven Cavity demo HOT 3
- update to using new version of pygmsh HOT 2
- rate_factor calculated using temperature output of HeatTransportSolver HOT 3
- import fails without ROL HOT 2
- Interpolating raster data onto 3D mesh
- Functions for surface/bed value extraction HOT 2
- Requirements not installed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from icepack.