# Execute this cell to load the notebook's style sheet, then ignore it
from IPython.core.display import HTML
css_file = '../style/custom.css'
HTML(open(css_file, "r").read())

"""
Explanation: Content under Creative Commons Attribution license CC-BY 4.0, code under BSD 3-Clause License © 2018  by D. Koehn, heterogeneous models are from this Jupyter notebook by Heiner Igel (@heinerigel), Florian Wölfl and Lion Krischer (@krischer) which is a supplemenatry material to the book Computational Seismology: A Practical Introduction, notebook style sheet by L.A. Barba, N.C. Clementi
End of explanation
"""


# Import Libraries 
# ----------------
import numpy as np
from numba import jit
import matplotlib
import matplotlib.pyplot as plt
from tew2.FD_2DAC import FD_2D_acoustic_JIT
from pylab import rcParams

# Ignore Warning Messages
# -----------------------
import warnings
warnings.filterwarnings("ignore")

from mpl_toolkits.axes_grid1 import make_axes_locatable

"""
Explanation: Viscoelasticity: Introduction
As introduction, we first distinguish different elastic "damping" effects of seismic waves and non-elastic damping. How can we describe seismic damping and what are the reasons?
End of explanation
"""


%matplotlib notebook
time, seis_hom = FD_2D_acoustic_JIT('hom')

"""
Explanation: "Damping" of elastic waves
Even without the incorporation of viscoelastic effects, seismic waves can be damped.
Due to geometrical spreading the seismic energy is distributed over the surface of the wavefront, as we can see in the acoustic modelling result below:
End of explanation
"""


%matplotlib notebook
time_rand, seis_rand = FD_2D_acoustic_JIT('rand')

"""
Explanation: Another way to damp the seismic wavefield is by scattering the seismic energy at small scale structures like the random medium in this acoustic example:
End of explanation
"""


%matplotlib notebook
# Compare FD seismograms
# ----------------------
# Define figure size
rcParams['figure.figsize'] = 7, 5

# plot seismogram hom. model
plt.plot(time, seis_hom, 'b-',lw=3,label="hom. medium") 

# plot seismogram random model
plt.plot(time_rand, seis_rand, 'r--',lw=3,label="random medium")
plt.xlim(0.4, time[-1])
plt.title('Seismogram comparison')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.legend()
plt.grid()
plt.show()

"""
Explanation: By comparing the seismograms for the homogeneous with the random medium we recongnize a significant amplitude difference. Note also the significant seismic coda
End of explanation
"""


