Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

r""" 

Operators for vector calculus 

 

This module defines the following operators for scalar, vector and tensor 

fields on any pseudo-Riemannian manifold (see 

:mod:`~sage.manifolds.differentiable.pseudo_riemannian`): 

 

- :func:`grad`: gradient of a scalar field 

- :func:`div`: divergence of a vector field, and more generally of a tensor 

field 

- :func:`curl`: curl of a vector field (3-dimensional case only) 

- :func:`laplacian`: Laplace-Beltrami operator acting on a scalar field, a 

vector field, or more generally a tensor field 

- :func:`dalembertian`: d'Alembert operator acting on a scalar field, a 

vector field, or more generally a tensor field, on a Lorentzian manifold 

 

All these operators are implemented as functions that call the appropriate 

method on their argument. The purpose is to allow one to use standard 

mathematical notations, e.g. to write ``curl(v)`` instead of ``v.curl()``. 

 

Note that the :func:`~sage.misc.functional.norm` operator is defined in the 

module :mod:`~sage.misc.functional`. 

 

AUTHORS: 

 

- Eric Gourgoulhon (2018): initial version 

 

""" 

 

#***************************************************************************** 

# Copyright (C) 2018 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr> 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 2 of the License, or 

# (at your option) any later version. 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

def grad(scalar): 

r""" 

Gradient operator. 

 

The *gradient* of a scalar field `f` on a pseudo-Riemannian manifold 

`(M,g)` is the vector field `\mathrm{grad}\, f` whose components in any 

coordinate frame are 

 

.. MATH:: 

 

(\mathrm{grad}\, f)^i = g^{ij} \frac{\partial F}{\partial x^j} 

 

where the `x^j`'s are the coordinates with respect to which the 

frame is defined and `F` is the chart function representing `f` in 

these coordinates: `f(p) = F(x^1(p),\ldots,x^n(p))` for any point `p` 

in the chart domain. 

In other words, the gradient of `f` is the vector field that is the 

`g`-dual of the differential of `f`. 

 

INPUT: 

 

- ``scalar`` -- scalar field `f`, as an instance of 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` 

 

OUTPUT: 

 

- instance of 

:class:`~sage.manifolds.differentiable.vectorfield.VectorField` 

representing `\mathrm{grad}\, f` 

 

EXAMPLES: 

 

Gradient of a scalar field in the Euclidean plane:: 

 

sage: M = Manifold(2, 'M', structure='Riemannian') 

sage: X.<x,y> = M.chart() 

sage: g = M.metric() 

sage: g[0,0], g[1,1] = 1, 1 

sage: f = M.scalar_field(sin(x*y), name='f') 

sage: from sage.manifolds.operators import grad 

sage: grad(f) 

Vector field grad(f) on the 2-dimensional Riemannian manifold M 

sage: grad(f).display() 

grad(f) = y*cos(x*y) d/dx + x*cos(x*y) d/dy 

 

See the method 

:meth:`~sage.manifolds.differentiable.scalarfield.DiffScalarField.gradient` 

of :class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` for 

more details and examples. 

 

""" 

return scalar.gradient() 

 

def div(tensor): 

r""" 

Divergence operator. 

 

Let `t` be a tensor field of type `(k,0)` with `k\geq 1` on a 

pseudo-Riemannian manifold `(M, g)`. The *divergence* of `t` is the tensor 

field of type `(k-1,0)` defined by 

 

.. MATH:: 

 

(\mathrm{div}\, t)^{a_1\ldots a_{k-1}} = 

\nabla_i t^{a_1\ldots a_{k-1} i} = 

(\nabla t)^{a_1\ldots a_{k-1} i}_{\phantom{a_1\ldots a_{k-1} i}\, i} 

 

where `\nabla` is the Levi-Civita connection of `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`). 

 

Note that the divergence is taken on the *last* index of the tensor field. 

This definition is extended to tensor fields of type `(k,l)` with 

`k\geq 0` and `l\geq 1`, by raising the last index with the metric `g`: 

`\mathrm{div}\, t` is then the tensor field of type `(k,l-1)` defined by 

 

.. MATH:: 

 

(\mathrm{div}\, t)^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\, b_1\ldots b_{l-1}} 

= \nabla_i (g^{ij} t^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\, b_1\ldots b_{l-1} j}) 

= (\nabla t^\sharp)^{a_1\ldots a_k i}_{\phantom{a_1\ldots a_k i}\, b_1\ldots b_{l-1} i} 

 

where `t^\sharp` is the tensor field deduced from `t` by raising the 

last index with the metric `g` (see 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.up`). 

 

INPUT: 

 

- ``tensor`` -- tensor field `t` on a pseudo-Riemannian manifold `(M,g)`, 

as an instance of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField` (possibly 

via one of its derived classes, like 

:class:`~sage.manifolds.differentiable.vectorfield.VectorField`) 

 

OUTPUT: 

 

- the divergence of ``tensor`` as an instance of either 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` 

if `(k,l)=(1,0)` (``tensor`` is a vector field) or `(k,l)=(0,1)` 

(``tensor`` is a 1-form) or of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField` 

if `k+l\geq 2` 

 

EXAMPLES: 

 

Divergence of a vector field in the Euclidean plane:: 

 

sage: M = Manifold(2, 'M', structure='Riemannian') 

sage: X.<x,y> = M.chart() 

sage: g = M.metric() 

sage: g[0,0], g[1,1] = 1, 1 

sage: v = M.vector_field('v') 

sage: v[:] = cos(x*y), sin(x*y) 

sage: v.display() 

v = cos(x*y) d/dx + sin(x*y) d/dy 

sage: from sage.manifolds.operators import div 

sage: s = div(v); s 

Scalar field div(v) on the 2-dimensional Riemannian manifold M 

sage: s.display() 

div(v): M --> R 

(x, y) |--> x*cos(x*y) - y*sin(x*y) 

 

See the method 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.divergence` 

of :class:`~sage.manifolds.differentiable.tensorfield.TensorField` for 

more details and examples. 

 

""" 

return tensor.divergence() 

 

def curl(vector): 

r""" 

Curl operator. 

 

The *curl* of a vector field `v` on an orientable pseudo-Riemannian 

manifold `(M,g)` of dimension 3 is the vector field defined by 

 

.. MATH:: 

 

\mathrm{curl}\, v = (*(\mathrm{d} v^\flat))^\sharp 

 

where `v^\flat` is the 1-form associated to `v` by the metric `g` (see 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.down`), 

`*(\mathrm{d} v^\flat)` is the Hodge dual with respect to `g` of the 

2-form `\mathrm{d} v^\flat` (exterior derivative of `v^\flat`) (see 

:meth:`~sage.manifolds.differentiable.diff_form.DiffForm.hodge_dual`) 

and 

`(*(\mathrm{d} v^\flat))^\sharp` is corresponding vector field by 

`g`-duality (see 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.up`). 

 

An alternative expression of the curl is 

 

.. MATH:: 

 

(\mathrm{curl}\, v)^i = \epsilon^{ijk} \nabla_j v_k 

 

where `\nabla` is the Levi-Civita connection of `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`) 

and `\epsilon` the volume 3-form (Levi-Civita tensor) of `g` (cf. 

:meth:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric.volume_form`) 

 

INPUT: 

 

- ``vector`` -- vector field on an orientable 3-dimensional 

pseudo-Riemannian manifold, as an instance of 

:class:`~sage.manifolds.differentiable.vectorfield.VectorField` 

 

OUTPUT: 

 

- instance of 

:class:`~sage.manifolds.differentiable.vectorfield.VectorField` 

representing the curl of ``vector`` 

 

EXAMPLES: 

 

Curl of a vector field in the Euclidean 3-space:: 

 

sage: M = Manifold(3, 'M', structure='Riemannian') 

sage: X.<x,y,z> = M.chart() 

sage: g = M.metric() 

sage: g[0,0], g[1,1], g[2,2] = 1, 1, 1 

sage: v = M.vector_field(name='v') 

sage: v[0], v[1] = sin(y), sin(x) 

sage: v.display() 

v = sin(y) d/dx + sin(x) d/dy 

sage: from sage.manifolds.operators import curl 

sage: s = curl(v); s 

Vector field curl(v) on the 3-dimensional Riemannian manifold M 

sage: s.display() 

curl(v) = (cos(x) - cos(y)) d/dz 

 

See the method 

:meth:`~sage.manifolds.differentiable.vectorfield.VectorField.curl` 

of :class:`~sage.manifolds.differentiable.vectorfield.VectorField` for more 

details and examples. 

 

""" 

return vector.curl() 

 

def laplacian(field): 

r""" 

Laplace-Beltrami operator. 

 

The *Laplace-Beltrami operator* on a pseudo-Riemannian manifold `(M,g)` 

is the operator 

 

.. MATH:: 

 

\Delta = \nabla_i \nabla^i = g^{ij} \nabla_i \nabla_j 

 

where `\nabla` is the Levi-Civita connection of the metric `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`) 

and `\nabla^i := g^{ij} \nabla_j` 

 

INPUT: 

 

- ``field`` -- a scalar field `f` (instance of 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField`) or a 

tensor field `f` (instance of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField`) on a 

pseudo-Riemannian manifold 

 

OUTPUT: 

 

- `\Delta f`, as an instance of 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` or of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField` 

 

EXAMPLES: 

 

Laplacian of a scalar field on the Euclidean plane:: 

 

sage: M = Manifold(2, 'M', structure='Riemannian') 

sage: X.<x,y> = M.chart() 

sage: g = M.metric() 

sage: g[0,0], g[1,1] = 1, 1 

sage: f = M.scalar_field(sin(x*y), name='f') 

sage: from sage.manifolds.operators import laplacian 

sage: Df = laplacian(f); Df 

Scalar field Delta(f) on the 2-dimensional Riemannian manifold M 

sage: Df.display() 

Delta(f): M --> R 

(x, y) |--> -(x^2 + y^2)*sin(x*y) 

 

The Laplacian of a scalar field is the divergence of its gradient:: 

 

sage: from sage.manifolds.operators import div, grad 

sage: Df == div(grad(f)) 

True 

 

See the method 

:meth:`~sage.manifolds.differentiable.scalarfield.DiffScalarField.laplacian` 

of :class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` and 

the method 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.laplacian` 

of :class:`~sage.manifolds.differentiable.tensorfield.TensorField` for 

more details and examples. 

 

""" 

return field.laplacian() 

 

def dalembertian(field): 

r""" 

d'Alembert operator. 

 

The *d'Alembert operator* or *d'Alembertian* on a Lorentzian manifold 

`(M,g)` is nothing but the Laplace-Beltrami operator: 

 

.. MATH:: 

 

\Box = \nabla_i \nabla^i = g^{ij} \nabla_i \nabla_j 

 

where `\nabla` is the Levi-Civita connection of the metric `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`) 

and `\nabla^i := g^{ij} \nabla_j` 

 

INPUT: 

 

- ``field`` -- a scalar field `f` (instance of 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField`) or a 

tensor field `f` (instance of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField`) on a 

pseudo-Riemannian manifold 

 

OUTPUT: 

 

- `\Box f`, as an instance of 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` or of 

:class:`~sage.manifolds.differentiable.tensorfield.TensorField` 

 

EXAMPLES: 

 

d'Alembertian of a scalar field in the 2-dimensional Minkowski spacetime:: 

 

sage: M = Manifold(2, 'M', structure='Lorentzian') 

sage: X.<t,x> = M.chart() 

sage: g = M.metric() 

sage: g[0,0], g[1,1] = -1, 1 

sage: f = M.scalar_field((x-t)^3 + (x+t)^2, name='f') 

sage: from sage.manifolds.operators import dalembertian 

sage: Df = dalembertian(f); Df 

Scalar field Box(f) on the 2-dimensional Lorentzian manifold M 

sage: Df.display() 

Box(f): M --> R 

(t, x) |--> 0 

 

See the method 

:meth:`~sage.manifolds.differentiable.scalarfield.DiffScalarField.dalembertian` 

of :class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` and 

the method 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.dalembertian` 

of :class:`~sage.manifolds.differentiable.tensorfield.TensorField` for 

more details and examples. 

 

""" 

return field.dalembertian() 

 

# NB: norm() is already defined in src/sage/misc/functional.py