ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 20 Apr 2022 06:20:22 +0200Non-dimensionalization of a Partial Differential Equationhttps://ask.sagemath.org/question/62056/non-dimensionalization-of-a-partial-differential-equation/Hello all, I am interested in replacing the variables of a Partial Differential Equation (PDE) for their non-dimensional counterparts and then group together the dimensionless numbers. I think I would only need to be able to replace the variables and also the derivative operators (as in a change of variables $\hat{x}=x/L$), grouping the dimensionless numbers can be done by hand.
It is a similar procedure to what is being done here: (en.wikipedia.org/wiki/Non-dimensionalization_and_scaling_of_the_Navier%E2%80%93Stokes_equations) . I was wondering if this can be done with SAGE.salazardetroyaWed, 20 Apr 2022 06:20:22 +0200https://ask.sagemath.org/question/62056/Evaluating gradient of numerically approximated functionhttps://ask.sagemath.org/question/59476/evaluating-gradient-of-numerically-approximated-function/Hello, I'd like to ask how to solve the following problem in Sage.
Let's suppose that I have a scalar function on R^3 (written in spherical coordinates) V(r,\theta,\phi), given by some tedious integral over a region in R^2: V(r,th,ph) = \int dx \int dy f(x,y,r,th,ph) (typical when calculating potentials by Green functions). The first question, how could I define such a function V in Sage? I guess it would involve approximating this function point by point by a 3-dim matrix containing results of numerical integration V(r0,th0,ph0) at different (r0,th0,ph0)...
Then, I would like to calculate the gradient of this V(r,th,ph) and plot streamlines or at least some plot of resulting vector field. I know how to do this when Sage is able to evaluate this gradient symbolically, but I don't know how to approximate it numerically and then make a plot.
I appreciate any help.
VonbatenBachMon, 25 Oct 2021 16:55:41 +0200https://ask.sagemath.org/question/59476/How do I use sage to check differential vector identities? Do I need to create an operator?https://ask.sagemath.org/question/58154/how-do-i-use-sage-to-check-differential-vector-identities-do-i-need-to-create-an-operator/Hi!<br>
I would like to check some differential vector identities. Any suggestion to achieve this goal would be welcomed.
<hr>
Example of a case I already worked out: $\vec{\nabla} (fg) = (\vec{\nabla}f) g + f (\vec{\nabla} g)$.
Code (I coudn't manage to put it on a single box, sorry):
<code>
from sage.manifolds.operators import * <br>
E.<x,y,z\> = EuclideanSpace()<br>
f = function('f')(x,y,z)<br>
g = function('g')(x,y,z)<br>
sff = E.scalar_field(sff, name = 'sff')<br>
sfg = E.scalar_field(sfg, name = 'sfg')<br>
sffg = E.scalar_field(sffg, name = 'sffg')<br>
grad(sffg) == grad(sff) * sfg + sff * grad(sfg)
</code>
Out: True
<hr>
**Example of what I want** to check:
$
\vec{\nabla} (\vec{A}\centerdot \vec{B}) = \vec{A}\times(\vec{\nabla} \times \vec{B}) +
\vec{B} \times (\vec{\nabla} \times \vec{A}) +
(\vec{A} \centerdot \vec{\nabla}) \vec{B} +
(\vec{B} \centerdot \vec{\nabla}) \vec{A}.
$
I don't know how to came to differential operators of the form $(\vec{A} \centerdot \vec{\nabla})$.
I tried (kind of hopelessly)
<code>newOperator=A.dot(grad())</code> without success.
How could I put sage to check identities like this one?
Thank you in advance.WilliansThu, 29 Jul 2021 22:18:10 +0200https://ask.sagemath.org/question/58154/Computing gradients of vector fields?https://ask.sagemath.org/question/52529/computing-gradients-of-vector-fields/Premise, I'm not working with special/general relativity, so it may be that the way the formalism is thought in SageMath does not fit perfectly my needs.
I'm trying to define vector and tensor fields in Euclidean space and then differentiate them. For example, I'm interested in calculating the gradient of a vector field, namely, the tensor field
$$
T_{ij} = \frac{dv_i}{dx_j}
$$
. However classes like `EuclideanSpace` only allow me to produce vector fields on which I can compute divergence and curl. Should I just create three scalar fields, one for each component, and go with that? Or are there ways to get `nabla` out as a vector and use it directly to operate on actual vectors and tensors (in which case I could use the tensor product, $T = \nabla \otimes v$)?Okarin86Fri, 17 Jul 2020 17:54:10 +0200https://ask.sagemath.org/question/52529/Gradient, Divergence, Curl and vector productshttps://ask.sagemath.org/question/10104/gradient-divergence-curl-and-vector-products/Are there implementations of vector product and the nabla operator yet? I can't find anything.KiMon, 21 Oct 2013 12:40:22 +0200https://ask.sagemath.org/question/10104/Define vector valued function of a vector of symbolic variables?https://ask.sagemath.org/question/24943/define-vector-valued-function-of-a-vector-of-symbolic-variables/ I have a gradient where each component may have a different number of symbolic arguments and get the following error when I run:
gradL<br>
(gradL[0]).arguments()<br>
(gradL[1]).arguments()<br>
(gradL[2]).arguments()<br>
s=[3,.5,.3]<br>
(gradL[0])(*s)<br>
(gradL[1])(*s)<br>
(gradL[2])(*s)<br>
(lam0*(x1 - 1.00000000000000) - log(x0) + log(-x0 + 1), lam0*x0 - log(x1) + log(-x1 + 1), x0*x1 - x0 + 0.500000000000000)<br>
(lam0, x0, x1)<br>
(lam0, x0, x1)<br>
(x0, x1)<br>
-2.10000000000000<br>
2.34729786038720<br>
Error in lines 8-8<br>
Traceback (most recent call last):
File "/projects/5511fe15-8085-4d1d-bdc7-c6bf6c99e693/.sagemathcloud/sage_server.py", line 865, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "sage/symbolic/expression.pyx", line 4382, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:24669)
File "sage/symbolic/ring.pyx", line 760, in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:8970)
ValueError: the number of arguments must be less than or equal to 2
I need to be able to to be able to define this as a vector valued function of a vector so that I can evaluate it using the entire argument set (lam0, x0, x1) where the missing arguments are ignored for the corresponding component. This is so I can def a function for scipy.optimize like:
def F(s):<br>
tmp=[]<br>
for ii in range(len(gradL)):<br>
tmp.append((gradL[ii])(*s))<br>
return tmp<br>
ssoln = scipy.optimize.broyden1(F, [.5,.5,.5], f_tol=1e-14)
I can't figure out how to accomplish this. Thanks for any help in advance.
-Steve
strangerlandSat, 22 Nov 2014 18:24:55 +0100https://ask.sagemath.org/question/24943/