Skip to content

Commit 9e647fb

Browse files
committed
Azure CI deploy v0.23.0 from 8c046219c
1 parent 97c497b commit 9e647fb

File tree

18,813 files changed

+7293064
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

18,813 files changed

+7293064
-1
lines changed

latest

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.22.2
1+
v0.23.0

v0.23.0/.buildinfo

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: c07cf8fc1e31271e5ee069621d0bbf26
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"\n# Maps: ComboMaps\n\nWe will use an example where we want a 1D layered earth as our model,\nbut we want to map this to a 2D discretization to do our forward\nmodeling. We will also assume that we are working in log conductivity\nstill, so after the transformation we map to conductivity space.\nTo do this we will introduce the vertical 1D map\n(:class:`simpeg.maps.SurjectVertical1D`), which does the first part of\nwhat we just described. The second part will be done by the\n:class:`simpeg.maps.ExpMap` described above.\n\n.. code-block:: python\n :linenos:\n\n M = discretize.TensorMesh([7,5])\n v1dMap = maps.SurjectVertical1D(M)\n expMap = maps.ExpMap(M)\n myMap = expMap * v1dMap\n m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters!\n sig = myMap * m\n\nIf you noticed, it was pretty easy to combine maps. What is even cooler\nis that the derivatives also are made for you (if everything goes\nright). Just to be sure that the derivative is correct, you should\nalways run the test on the mapping that you create.\n"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"import discretize\nfrom simpeg import maps\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef run(plotIt=True):\n M = discretize.TensorMesh([7, 5])\n v1dMap = maps.SurjectVertical1D(M)\n expMap = maps.ExpMap(M)\n myMap = expMap * v1dMap\n m = np.r_[0.2, 1, 0.1, 2, 2.9] # only 5 model parameters!\n sig = myMap * m\n\n if not plotIt:\n return\n\n figs, axs = plt.subplots(1, 2)\n axs[0].plot(m, M.cell_centers_y, \"b-o\")\n axs[0].set_title(\"Model\")\n axs[0].set_ylabel(\"Depth, y\")\n axs[0].set_xlabel(\"Value, $m_i$\")\n axs[0].set_xlim(0, 3)\n axs[0].set_ylim(0, 1)\n clbar = plt.colorbar(\n M.plot_image(sig, ax=axs[1], grid=True, grid_opts=dict(color=\"grey\"))[0]\n )\n axs[1].set_title(\"Physical Property\")\n axs[1].set_ylabel(\"Depth, y\")\n clbar.set_label(r\"$\\sigma = \\exp(\\mathbf{P}m)$\")\n plt.tight_layout()\n\n\nif __name__ == \"__main__\":\n run()\n plt.show()"
19+
]
20+
}
21+
],
22+
"metadata": {
23+
"kernelspec": {
24+
"display_name": "Python 3",
25+
"language": "python",
26+
"name": "python3"
27+
},
28+
"language_info": {
29+
"codemirror_mode": {
30+
"name": "ipython",
31+
"version": 3
32+
},
33+
"file_extension": ".py",
34+
"mimetype": "text/x-python",
35+
"name": "python",
36+
"nbconvert_exporter": "python",
37+
"pygments_lexer": "ipython3",
38+
"version": "3.10.15"
39+
}
40+
},
41+
"nbformat": 4,
42+
"nbformat_minor": 0
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
"""
2+
1D Forward Simulation with User-Defined Waveforms
3+
=================================================
4+
5+
For time-domain electromagnetic problems, the response depends strongly on the
6+
souce waveforms. In this tutorial, we construct a set of waveforms of different
7+
types and simulate the response for a halfspace. Many types of waveforms can
8+
be constructed within *simpeg.electromagnetics.time_domain_1d*. These include:
9+
10+
- the unit step off waveform
11+
- a set of basic waveforms: rectangular, triangular, quarter sine, etc...
12+
- a set of system-specific waveforms: SkyTEM, VTEM, GeoTEM, etc...
13+
- fully customized waveforms
14+
15+
16+
"""
17+
18+
#####################################################
19+
# Import Modules
20+
# --------------
21+
#
22+
23+
import numpy as np
24+
import matplotlib as mpl
25+
from matplotlib import pyplot as plt
26+
27+
mpl.rcParams.update({"font.size": 16})
28+
29+
from simpeg import maps
30+
import simpeg.electromagnetics.time_domain as tdem
31+
32+
33+
#####################################################################
34+
# Define Waveforms
35+
# ----------------
36+
#
37+
# Here, we define the set of waveforms that will be used to simulated the
38+
# TEM response.
39+
#
40+
41+
# Unit stepoff waveform can be defined directly
42+
stepoff_waveform = tdem.sources.StepOffWaveform()
43+
44+
# Rectangular waveform. The user may customize the waveform by setting the start
45+
# time, end time and on time amplitude for the current waveform.
46+
eps = 1e-6
47+
ramp_on = np.r_[-0.004, -0.004 + eps]
48+
ramp_off = np.r_[-eps, 0.0]
49+
rectangular_waveform = tdem.sources.TrapezoidWaveform(
50+
ramp_on=ramp_on, ramp_off=ramp_off
51+
)
52+
53+
# Triangular waveform. The user may customize the waveform by setting the start
54+
# time, peak time, end time and peak amplitude for the current waveform.
55+
eps = 1e-8
56+
start_time = -0.02
57+
peak_time = -0.01
58+
off_time = 0.0
59+
triangle_waveform = tdem.sources.TriangularWaveform(
60+
start_time=start_time, peak_time=peak_time, off_time=off_time
61+
)
62+
63+
# Quarter-sine ramp-off
64+
ramp_on = np.r_[-0.02, -0.01]
65+
ramp_off = np.r_[-0.01, 0.0]
66+
qs_waveform = tdem.sources.QuarterSineRampOnWaveform(ramp_on=ramp_on, ramp_off=ramp_off)
67+
68+
69+
# General waveform. This is a fully general way to define the waveform.
70+
# The use simply provides times and the current.
71+
def custom_waveform(t, tmax):
72+
out = np.cos(0.5 * np.pi * (t - tmax) / (tmax + 0.02))
73+
out[t >= tmax] = 1 + (t[t >= tmax] - tmax) / tmax
74+
return out
75+
76+
77+
waveform_times = np.r_[np.linspace(-0.02, -0.011, 10), -np.logspace(-2, -6, 61), 0.0]
78+
waveform_current = custom_waveform(waveform_times, -0.0055)
79+
general_waveform = tdem.sources.PiecewiseLinearWaveform(
80+
times=waveform_times, currents=waveform_current
81+
)
82+
83+
###############################################
84+
# Plot the Waveforms
85+
# ------------------
86+
#
87+
# Here, we plot the set of waveforms that are used in the simulation.
88+
#
89+
90+
fig = plt.figure(figsize=(8, 6))
91+
ax = fig.add_axes([0.1, 0.1, 0.85, 0.8])
92+
93+
ax.plot(np.r_[-2e-2, 0.0, 1e-10, 1e-3], np.r_[1.0, 1.0, 0.0, 0.0], "k", lw=3)
94+
plotting_current = [rectangular_waveform.eval(t) for t in waveform_times]
95+
ax.plot(waveform_times, plotting_current, "r", lw=2)
96+
plotting_current = [triangle_waveform.eval(t) for t in waveform_times]
97+
ax.plot(waveform_times, plotting_current, "b", lw=2)
98+
plotting_current = [qs_waveform.eval(t) for t in waveform_times]
99+
ax.plot(waveform_times, plotting_current, "g", lw=2)
100+
plotting_current = [general_waveform.eval(t) for t in waveform_times]
101+
ax.plot(waveform_times, plotting_current, "c", lw=2)
102+
103+
ax.grid()
104+
ax.set_xlim([waveform_times.min(), 1e-3])
105+
ax.set_xlabel("Time (s)")
106+
ax.set_ylabel("Current (A)")
107+
ax.set_title("Waveforms")
108+
ax.legend(
109+
["Step-off", "Rectangular", "Triangle", "Quarter-Sine", "General"], loc="lower left"
110+
)
111+
112+
113+
#####################################################################
114+
# Create Survey
115+
# -------------
116+
#
117+
# The waveform is a property of the source. So for each waveform, we will need
118+
# to define a separate source object. For simplicity, all sources will be
119+
# horizontal loops with a radius of 10 m.
120+
#
121+
122+
# Define a receiver list. In this case, we measure the vertical component of
123+
# db/dt. Thus we only have a single receiver in the list.
124+
receiver_location = np.array([0.0, 0.0, 0.0])
125+
receiver_orientation = "z" # "x", "y" or "z"
126+
times = np.logspace(-4, -1, 41) # time channels
127+
128+
receiver_list = [
129+
tdem.receivers.PointMagneticFluxTimeDerivative(
130+
receiver_location, times, orientation=receiver_orientation
131+
)
132+
]
133+
134+
# Source properties. If you defined the true waveform (not normalized), the current amplitude
135+
# should be set to 1. Otherwise you will be accounting for the maximum current
136+
# amplitude twice!!!
137+
source_location = np.array([0.0, 0.0, 0.0])
138+
source_radius = 10.0
139+
current_amplitude = 1.0
140+
141+
source_list = []
142+
143+
# Stepoff Waveform
144+
source_list.append(
145+
tdem.sources.CircularLoop(
146+
receiver_list=receiver_list,
147+
location=source_location,
148+
waveform=stepoff_waveform,
149+
radius=source_radius,
150+
current=current_amplitude,
151+
)
152+
)
153+
154+
# Rectangular Waveform
155+
source_list.append(
156+
tdem.sources.CircularLoop(
157+
receiver_list=receiver_list,
158+
location=source_location,
159+
waveform=rectangular_waveform,
160+
radius=source_radius,
161+
current=current_amplitude,
162+
)
163+
)
164+
165+
# Triangle Waveform
166+
source_list.append(
167+
tdem.sources.CircularLoop(
168+
receiver_list=receiver_list,
169+
location=source_location,
170+
waveform=triangle_waveform,
171+
radius=source_radius,
172+
current=current_amplitude,
173+
)
174+
)
175+
176+
# Quarter-sine ramp-off Waveform
177+
source_list.append(
178+
tdem.sources.CircularLoop(
179+
receiver_list=receiver_list,
180+
location=source_location,
181+
waveform=qs_waveform,
182+
radius=source_radius,
183+
current=current_amplitude,
184+
)
185+
)
186+
187+
# General Waveform
188+
source_list.append(
189+
tdem.sources.CircularLoop(
190+
receiver_list=receiver_list,
191+
location=source_location,
192+
waveform=general_waveform,
193+
radius=source_radius,
194+
current=current_amplitude,
195+
)
196+
)
197+
198+
# Survey
199+
survey = tdem.Survey(source_list)
200+
201+
###############################################
202+
# Defining a 1D Layered Earth Model
203+
# ---------------------------------
204+
#
205+
# Here, we define the layer thicknesses and electrical conductivities for our
206+
# 1D simulation. If we have N layers, we define N electrical conductivity
207+
# values and N-1 layer thicknesses. The lowest layer is assumed to extend to
208+
# infinity.
209+
#
210+
211+
# Layer thicknesses
212+
thicknesses = np.array([40.0, 40.0])
213+
n_layer = len(thicknesses) + 1
214+
215+
# half-space physical properties
216+
sigma = 1e-2
217+
eta = 0.5
218+
tau = 0.01
219+
c = 0.5
220+
chi = 0.0
221+
222+
# physical property models
223+
sigma_model = sigma * np.ones(n_layer)
224+
eta_model = eta * np.ones(n_layer)
225+
tau_model = tau * np.ones(n_layer)
226+
c_model = c * np.ones(n_layer)
227+
mu0 = 4 * np.pi * 1e-7
228+
mu_model = mu0 * (1 + chi) * np.ones(n_layer)
229+
230+
# Define a mapping for conductivities
231+
model_mapping = maps.IdentityMap(nP=n_layer)
232+
233+
#######################################################################
234+
# Define the Forward Simulation and Predict Data
235+
# ----------------------------------------------
236+
#
237+
238+
# Define the simulation
239+
simulation = tdem.Simulation1DLayered(
240+
survey=survey, thicknesses=thicknesses, sigmaMap=model_mapping, mu=mu_model
241+
)
242+
243+
# Predict data for a given model
244+
dpred = simulation.dpred(sigma_model)
245+
246+
#######################################################################
247+
# Plotting Results
248+
# -------------------------------------------------
249+
#
250+
251+
fig = plt.figure(figsize=(8, 8))
252+
d = np.reshape(dpred, (len(source_list), len(times))).T
253+
ax = fig.add_axes([0.15, 0.15, 0.8, 0.75])
254+
colorlist = ["k", "b", "r", "g", "c"]
255+
for ii, k in enumerate(colorlist):
256+
ax.loglog(times, np.abs(d[:, ii]), k, lw=2)
257+
258+
ax.set_xlim([times.min(), times.max()])
259+
ax.grid()
260+
ax.legend(["Step-off", "Rectangular", "Triangle", "Quarter-Sine", "General"])
261+
ax.set_xlabel("Times (s)")
262+
ax.set_ylabel("|dB/dt| (T/s)")
263+
ax.set_title("TEM Response")

v0.23.0/_downloads/09529b559fbda90a447993ef9cc0e22d/plot_booky_1D_time_freq_inv.ipynb

+43
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)