You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: FWI_forward_adjoint/FWIpart1.md
+6-12Lines changed: 6 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -67,8 +67,7 @@ At the core of Devito's symbolic API are two symbolic types that behave like Sym
67
67
68
68
To demonstrate Devito's symbolic capabilities, let us consider a time-dependent function $\mathbf{u}(\text{time}, x, y)$ representing the discrete forward wavefield. We can define this as a `TimeFunction` object in Devito:
69
69
70
-
```
71
-
python
70
+
```python
72
71
u = TimeFunction(name="u", shape=model.shape_domain, time_order=2,
73
72
space_order=2, save=True, time_dim=nt)
74
73
```
@@ -83,8 +82,7 @@ derivatives using shorthand expressions, such as `u.dx` and `u.dx2` to
83
82
denote $\frac{\partial u}{\partial x}$ and $\frac{\partial^2
84
83
u}{\partial x^2}$ respectively.
85
84
86
-
```
87
-
python
85
+
```python
88
86
In []: u
89
87
Out[]: u(time, x, y)
90
88
@@ -97,8 +95,7 @@ python
97
95
98
96
Using the automatic derivation of derivative expressions we can now implement a discretized expression for Equation @WE without the source term $q(x,y,t;x_s, y_s)$. The `model` object which we created earlier, already contains the squared slowness $\mathbf{m}$ and damping term $\mathbf{\eta}$ as `Function` objects:
In Python, we can rearrange our `pde` expression automatically using the SymPy utility function `solve`, to create a stencil expression that defines the update of the wavefield for the new time step $\mathbf{u}(\text{time}+s)$, which is expressed as `u.forward` in Devito:
119
116
120
-
```
121
-
python
117
+
```python
122
118
# Rearrange PDE to obtain new wavefield at next time step
123
119
stencil = Eq(u.forward, solve(pde, u.forward)[0])
124
120
```
@@ -150,8 +146,7 @@ The `src.inject` now injects the current time sample of the Ricker wavelet (weig
150
146
151
147
There is a corresponding wrapper function for receivers as well, which creates a `SparseFunction` object for a given number `npoint` of receivers, number `nt` of time samples and specified receiver coordinates `rec_coords` (with `ndim=2`, since we have a two-dimensional example).
0 commit comments