|
8 | 8 | from scipy.constants import mu_0 |
9 | 9 | from scipy.sparse import csr_matrix |
10 | 10 | from ...survey import BaseRx |
11 | | -from simpeg.utils import mkvc |
12 | 11 |
|
13 | 12 |
|
14 | 13 | def _alpha(src): |
@@ -1145,20 +1144,25 @@ def _eval_apparent_conductivity_deriv( |
1145 | 1144 | # ADJOINT |
1146 | 1145 | if adjoint: |
1147 | 1146 | # Compute: J_T * v = d_top_T * a_v + d_bot_T * b |
1148 | | - a_v = fact * v / bot # term 1 |
1149 | | - b_v = -fact * top * v / bot**2 # term 2 |
1150 | | - |
1151 | | - a_v = np.repeat(mkvc(a_v, n_dims=2), 2, axis=-1) |
1152 | | - b_v = np.repeat(mkvc(b_v, n_dims=2), 2, axis=-1) |
1153 | | - |
1154 | | - hx *= a_v |
1155 | | - hy *= a_v |
1156 | | - hz *= a_v |
1157 | | - ex *= b_v |
1158 | | - ey *= b_v |
1159 | | - |
1160 | | - e_v = 2 * (Pex.T @ ex + Pey.T @ ey).conjugate() |
1161 | | - h_v = 2 * (Phx.T @ hx + Phy.T @ hy + Phz.T @ hz).conjugate() |
| 1147 | + a_v = fact * np.c_[v] / bot[:, None] # term 1 |
| 1148 | + b_v = np.c_[v] * (-fact * top / (bot**2))[:, None] # term 2 |
| 1149 | + |
| 1150 | + ghx_v = np.einsum("ij,ik->ijk", a_v, hx).reshape((hx.shape[0], -1)) |
| 1151 | + ghy_v = np.einsum("ij,ik->ijk", a_v, hy).reshape((hy.shape[0], -1)) |
| 1152 | + ghz_v = np.einsum("ij,ik->ijk", a_v, hz).reshape((hz.shape[0], -1)) |
| 1153 | + gex_v = np.einsum("ij,ik->ijk", b_v, ex).reshape((ex.shape[0], -1)) |
| 1154 | + gey_v = np.einsum("ij,ik->ijk", b_v, ey).reshape((ey.shape[0], -1)) |
| 1155 | + e_v = ( |
| 1156 | + 2 * (Pex.T @ csr_matrix(gex_v) + Pey.T @ csr_matrix(gey_v)).conjugate() |
| 1157 | + ) |
| 1158 | + h_v = ( |
| 1159 | + 2 |
| 1160 | + * ( |
| 1161 | + Phx.T @ csr_matrix(ghx_v) |
| 1162 | + + Phy.T @ csr_matrix(ghy_v) |
| 1163 | + + Phz.T @ csr_matrix(ghz_v) |
| 1164 | + ).conjugate() |
| 1165 | + ) |
1162 | 1166 |
|
1163 | 1167 | fu_e_v, fm_e_v = f._eDeriv(src, None, e_v, adjoint=True) |
1164 | 1168 | fu_h_v, fm_h_v = f._hDeriv(src, None, h_v, adjoint=True) |
|
0 commit comments