Skip to content

Commit

Permalink
Azure CI deploy v0.22.1 from c699a84f6
Browse files Browse the repository at this point in the history
  • Loading branch information
simpeg-bot committed Jul 5, 2024
1 parent e91f3d7 commit cbcf6c1
Show file tree
Hide file tree
Showing 18,486 changed files with 7,564,588 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion latest
4 changes: 4 additions & 0 deletions v0.22.1/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 601fea87be90695f70889acfccae610f
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\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"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"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()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.19"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
"""
1D Forward Simulation with User-Defined Waveforms
=================================================
For time-domain electromagnetic problems, the response depends strongly on the
souce waveforms. In this tutorial, we construct a set of waveforms of different
types and simulate the response for a halfspace. Many types of waveforms can
be constructed within *simpeg.electromagnetics.time_domain_1d*. These include:
- the unit step off waveform
- a set of basic waveforms: rectangular, triangular, quarter sine, etc...
- a set of system-specific waveforms: SkyTEM, VTEM, GeoTEM, etc...
- fully customized waveforms
"""

#####################################################
# Import Modules
# --------------
#

import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt

mpl.rcParams.update({"font.size": 16})

from simpeg import maps
import simpeg.electromagnetics.time_domain as tdem


#####################################################################
# Define Waveforms
# ----------------
#
# Here, we define the set of waveforms that will be used to simulated the
# TEM response.
#

# Unit stepoff waveform can be defined directly
stepoff_waveform = tdem.sources.StepOffWaveform()

# Rectangular waveform. The user may customize the waveform by setting the start
# time, end time and on time amplitude for the current waveform.
eps = 1e-6
ramp_on = np.r_[-0.004, -0.004 + eps]
ramp_off = np.r_[-eps, 0.0]
rectangular_waveform = tdem.sources.TrapezoidWaveform(
ramp_on=ramp_on, ramp_off=ramp_off
)

# Triangular waveform. The user may customize the waveform by setting the start
# time, peak time, end time and peak amplitude for the current waveform.
eps = 1e-8
start_time = -0.02
peak_time = -0.01
off_time = 0.0
triangle_waveform = tdem.sources.TriangularWaveform(
start_time=start_time, peak_time=peak_time, off_time=off_time
)

# Quarter-sine ramp-off
ramp_on = np.r_[-0.02, -0.01]
ramp_off = np.r_[-0.01, 0.0]
qs_waveform = tdem.sources.QuarterSineRampOnWaveform(ramp_on=ramp_on, ramp_off=ramp_off)


# General waveform. This is a fully general way to define the waveform.
# The use simply provides times and the current.
def custom_waveform(t, tmax):
out = np.cos(0.5 * np.pi * (t - tmax) / (tmax + 0.02))
out[t >= tmax] = 1 + (t[t >= tmax] - tmax) / tmax
return out


waveform_times = np.r_[np.linspace(-0.02, -0.011, 10), -np.logspace(-2, -6, 61), 0.0]
waveform_current = custom_waveform(waveform_times, -0.0055)
general_waveform = tdem.sources.PiecewiseLinearWaveform(
times=waveform_times, currents=waveform_current
)

###############################################
# Plot the Waveforms
# ------------------
#
# Here, we plot the set of waveforms that are used in the simulation.
#

fig = plt.figure(figsize=(8, 6))
ax = fig.add_axes([0.1, 0.1, 0.85, 0.8])

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)
plotting_current = [rectangular_waveform.eval(t) for t in waveform_times]
ax.plot(waveform_times, plotting_current, "r", lw=2)
plotting_current = [triangle_waveform.eval(t) for t in waveform_times]
ax.plot(waveform_times, plotting_current, "b", lw=2)
plotting_current = [qs_waveform.eval(t) for t in waveform_times]
ax.plot(waveform_times, plotting_current, "g", lw=2)
plotting_current = [general_waveform.eval(t) for t in waveform_times]
ax.plot(waveform_times, plotting_current, "c", lw=2)

ax.grid()
ax.set_xlim([waveform_times.min(), 1e-3])
ax.set_xlabel("Time (s)")
ax.set_ylabel("Current (A)")
ax.set_title("Waveforms")
ax.legend(
["Step-off", "Rectangular", "Triangle", "Quarter-Sine", "General"], loc="lower left"
)


#####################################################################
# Create Survey
# -------------
#
# The waveform is a property of the source. So for each waveform, we will need
# to define a separate source object. For simplicity, all sources will be
# horizontal loops with a radius of 10 m.
#

# Define a receiver list. In this case, we measure the vertical component of
# db/dt. Thus we only have a single receiver in the list.
receiver_location = np.array([0.0, 0.0, 0.0])
receiver_orientation = "z" # "x", "y" or "z"
times = np.logspace(-4, -1, 41) # time channels

receiver_list = [
tdem.receivers.PointMagneticFluxTimeDerivative(
receiver_location, times, orientation=receiver_orientation
)
]

# Source properties. If you defined the true waveform (not normalized), the current amplitude
# should be set to 1. Otherwise you will be accounting for the maximum current
# amplitude twice!!!
source_location = np.array([0.0, 0.0, 0.0])
source_radius = 10.0
current_amplitude = 1.0

source_list = []

# Stepoff Waveform
source_list.append(
tdem.sources.CircularLoop(
receiver_list=receiver_list,
location=source_location,
waveform=stepoff_waveform,
radius=source_radius,
current=current_amplitude,
)
)

# Rectangular Waveform
source_list.append(
tdem.sources.CircularLoop(
receiver_list=receiver_list,
location=source_location,
waveform=rectangular_waveform,
radius=source_radius,
current=current_amplitude,
)
)

# Triangle Waveform
source_list.append(
tdem.sources.CircularLoop(
receiver_list=receiver_list,
location=source_location,
waveform=triangle_waveform,
radius=source_radius,
current=current_amplitude,
)
)

# Quarter-sine ramp-off Waveform
source_list.append(
tdem.sources.CircularLoop(
receiver_list=receiver_list,
location=source_location,
waveform=qs_waveform,
radius=source_radius,
current=current_amplitude,
)
)

# General Waveform
source_list.append(
tdem.sources.CircularLoop(
receiver_list=receiver_list,
location=source_location,
waveform=general_waveform,
radius=source_radius,
current=current_amplitude,
)
)

# Survey
survey = tdem.Survey(source_list)

###############################################
# Defining a 1D Layered Earth Model
# ---------------------------------
#
# Here, we define the layer thicknesses and electrical conductivities for our
# 1D simulation. If we have N layers, we define N electrical conductivity
# values and N-1 layer thicknesses. The lowest layer is assumed to extend to
# infinity.
#

# Layer thicknesses
thicknesses = np.array([40.0, 40.0])
n_layer = len(thicknesses) + 1

# half-space physical properties
sigma = 1e-2
eta = 0.5
tau = 0.01
c = 0.5
chi = 0.0

# physical property models
sigma_model = sigma * np.ones(n_layer)
eta_model = eta * np.ones(n_layer)
tau_model = tau * np.ones(n_layer)
c_model = c * np.ones(n_layer)
mu0 = 4 * np.pi * 1e-7
mu_model = mu0 * (1 + chi) * np.ones(n_layer)

# Define a mapping for conductivities
model_mapping = maps.IdentityMap(nP=n_layer)

#######################################################################
# Define the Forward Simulation and Predict Data
# ----------------------------------------------
#

# Define the simulation
simulation = tdem.Simulation1DLayered(
survey=survey, thicknesses=thicknesses, sigmaMap=model_mapping, mu=mu_model
)

# Predict data for a given model
dpred = simulation.dpred(sigma_model)

#######################################################################
# Plotting Results
# -------------------------------------------------
#

fig = plt.figure(figsize=(8, 8))
d = np.reshape(dpred, (len(source_list), len(times))).T
ax = fig.add_axes([0.15, 0.15, 0.8, 0.75])
colorlist = ["k", "b", "r", "g", "c"]
for ii, k in enumerate(colorlist):
ax.loglog(times, np.abs(d[:, ii]), k, lw=2)

ax.set_xlim([times.min(), times.max()])
ax.grid()
ax.legend(["Step-off", "Rectangular", "Triangle", "Quarter-Sine", "General"])
ax.set_xlabel("Times (s)")
ax.set_ylabel("|dB/dt| (T/s)")
ax.set_title("TEM Response")

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cbcf6c1

Please sign in to comment.