#!/usr/bin/env python
# coding: utf-8
# This is the Jupyter Notebook, an interactive coding and computation environment. For this lab, you do not have to write any code, you will only be running it.
#
# To use the notebook:
# - "Shift + Enter" runs the code within the cell (so does the forward arrow button near the top of the document)
# - You can alter variables and re-run cells
# - If you want to start with a clean slate, restart the Kernel either by going to the top, clicking on Kernel: Restart, or by "esc + 00" (if you do this, you will need to re-run the following block of code before running any other cells in the notebook)
# In[1]:
get_ipython().run_line_magic('matplotlib', 'inline')
from IPython.display import display
from em_examples.PlanewaveWidgetTD import PlanewaveWidget, InteractivePlaneProfile
from em_examples.VolumeWidgetPlane import InteractivePlanes, plotObj3D
# # Planewave propagation in a Whole-space (time-domain)
# # Purpose
#
# We visualizae downward propagating planewave in the homogeneous earth medium with impulse excitation. With the two apps: a) Plane wave app and b) Profile app, we understand fundamental concepts of planewave propagation in time-domain.
# # Set up
#
# Planewave EM solutions for homogeneous earth with impulse exictation can be expressed as
#
# $$\mathbf{e}(t) = -E_0 \frac{(\mu\sigma)^{1/2}z}{2 \pi^{1/2} t^{3/2}} e^{-\mu\sigma z^2 / (4t)} \mathbf{u_x}$$
#
# $$ \mathbf{h}(t) = E_0 \sqrt{\dfrac{\sigma}{\pi\mu t}}\, e^{-\mu\sigma z^2/4t} \, \mathbf{u_y} $$
#
# Note that this dervation based upon quasi-static approximation, which ignores displacement currents. For detailed derivation see EM geosci.
# In[2]:
ax = plotObj3D()
# # Planewave app
#
# ## Parameters:
#
# - Field: Type of EM fields ("Ex": electric field, "Hy": magnetic field)
# - Time: Time (s)
# - Sigma: Conductivity of homogeneous earth (S/m)
# - Scale: Choose "log" or "linear" scale
#
# In[3]:
dwidget = PlanewaveWidget()
Q = dwidget.InteractivePlaneWave()
display(Q)
# # Profile app
#
# We visualize EM fields at vertical profile
#
# ## Parameters:
#
# - **Field**: Ex, Hy, and Impedance
# - ** $\sigma$ **: Conductivity (S/m)
# - **Scale**: Log10 or Linear scale
# - **$t$**: Time
#
# In[4]:
display(InteractivePlaneProfile())