In [2]:
import sys, os
import matplotlib.pyplot as plt
# adjust some settings for matplotlib
from matplotlib import rcParams
# print rcParams
rcParams['font.size'] = 15
# determine path of repository to set paths corretly below
os.chdir(r'/Users/flow/git/pynoddy/docs/notebooks/')# some basic module imports
repo_path = os.path.realpath('../..')
import pynoddy
In [129]:
reload(pynoddy.history)
reload(pynoddy.events)
reload(pynoddy.output)
# Change to sandbox directory to store results
os.chdir(os.path.join(repo_path, 'sandbox'))
# Path to exmaple directory in this repository
example_directory = os.path.join(repo_path,'examples')
# Compute noddy model for history file
history = 'simple_two_faults.his'
history_ori = os.path.join(example_directory, history)
output_name = 'noddy_out'
H1 = pynoddy.history.NoddyHistory(history_ori)
# Before we do anything else, let's actually define the cube size here to
# adjust the resolution for all subsequent examples
H1.change_cube_size(100)
# compute model - note: not strictly required, here just to ensure changed cube size
H1.write_history(history)
pynoddy.compute_model(history, output_name)
his_full_3d = pynoddy.history.NoddyHistory(history)
block_full_3d = pynoddy.output.NoddyOutput(output_name)
# now create the slice history with the same cube size
H1 = pynoddy.history.NoddyHistory(os.path.join(example_directory,
"simple_two_faults_slice.his"))
H1.change_cube_size(100)
# compute model - note: not strictly required, here just to ensure changed cube size
H1.write_history(history)
pynoddy.compute_model(history, output_name)
his_2d_slice = pynoddy.history.NoddyHistory(history)
block_2d_slice = pynoddy.output.NoddyOutput(output_name)
In [130]:
block_full_3d.nx, block_full_3d.ny, block_full_3d.nz
Out[130]:
In [131]:
block_2d_slice.nx, block_2d_slice.ny, block_2d_slice.nz
Out[131]:
In [132]:
block_full_3d.plot_section('x', position=20)
In [135]:
block_2d_slice.plot_section('y', position=0)
In [136]:
block_2d_slice.block = np.array(block_2d_slice.block)
In [137]:
block_2d_slice.export_to_vtk(vtk_filename = "slice_model")
In [28]:
block_full_3d.export_to_vtk()
In [5]:
reload(pynoddy.history)
# Change to sandbox directory to store results
os.chdir(os.path.join(repo_path, 'sandbox'))
# Path to exmaple directory in this repository
example_directory = os.path.join(repo_path,'examples')
In [123]:
noddy_his = os.path.join(example_directory, "slightly_complicated.his")
noddy_out = 'slightly_complicated_out'
# recompute model
pynoddy.compute_model(noddy_his, noddy_out)
In [124]:
f = open(noddy_out + ".g12").readlines()
In [125]:
len(f[0].strip().split("\t"))
Out[125]:
In [126]:
# Now open output file
reload(pynoddy.output)
no = pynoddy.output.NoddyOutput(noddy_out)
print no.block.shape
imshow(no.block[10,:,:], interpolation = 'nearest')
no.export_to_vtk(vtk_filename = noddy_out)
In [127]:
no.plot_section('x')
no.plot_section('y')
no.plot_section('z')
In [114]:
im = imshow(no.block[40,:,:], interpolation='nearest')
In [91]:
nh = pynoddy.history.NoddyHistory(noddy_his)
In [94]:
nh.events[1].__dict__
Out[94]:
In [16]:
?? np.loadtxt
Void ratio as degree of compactness
In [1]:
def e(n): return n/(1-n)
In [2]:
e(0.5)
Out[2]:
In [8]:
ns = np.linspace(0.01,0.8)
In [18]:
plt.plot(ns, e(ns))
plt.title('Void ratio as degree of compactness')
plt.xlabel('Eulerian porosity')
plt.ylabel('Void ratio')
plt.axvline(0.5, color = 'k', linestyle = ':')
plt.axhline(1.0, color = 'k', linestyle = ':')
Out[18]:
In [2]:
import sys, os
import matplotlib.pyplot as plt
# adjust some settings for matplotlib
from matplotlib import rcParams
# print rcParams
rcParams['font.size'] = 15
# determine path of repository to set paths corretly below
os.chdir(r'/Users/flow/git/pynoddy/docs/notebooks/')# some basic module imports
repo_path = os.path.realpath('../..')
import pynoddy
In [9]:
reload(pynoddy.history)
reload(pynoddy.events)
reload(pynoddy.output)
# Change to sandbox directory to store results
os.chdir(os.path.join(repo_path, 'sandbox'))
# Path to exmaple directory in this repository
example_directory = os.path.join(repo_path,'examples')
# Compute noddy model for history file
history = 'simple_two_faults.his'
history_ori = os.path.join(example_directory, history)
output_name = 'noddy_out'
H1 = pynoddy.history.NoddyHistory(history_ori)
# Before we do anything else, let's actually define the cube size here to
# adjust the resolution for all subsequent examples
H1.change_cube_size(100)
# compute model - note: not strictly required, here just to ensure changed cube size
H1.write_history(history)
pynoddy.compute_model(history, output_name)
In [4]:
no = pynoddy.output.NoddyOutput(output_name)
In [4]:
import pynoddy.experiment
In [7]:
ne = pynoddy.experiment.Experiment(1)
In [10]:
ne.load_history(history)
In [12]:
ne.determine_events()
In [14]:
ne.info()
Check weighting terms:
$$\frac{a - b}{a + b}$$
In [19]:
a = 2
xs = np.arange(0,-2,-0.1)
def func(a,b):
return (a-b) / (a+b)
plot(xs, func(a, a + xs))
Out[19]:
In [23]:
func(1,2.)
Out[23]:
In [24]:
np.linalg.inv(np.array([[-2,1],[1,-2]]))
Out[24]:
In [26]:
A = np.array([[-2,1],[1,-2]])
In [27]:
np.linalg.det(A)
Out[27]:
In [28]:
b = [-1, -4]
In [29]:
np.linalg.solve(A,b)
Out[29]:
In [ ]:
In [1]:
A = np.array([[1,0],[0,1]])
In [2]:
np.linalg.eig(A)
Out[2]:
In [5]:
np.linalg.eigvals(A)
Out[5]:
In [8]:
A = np.array([[1,0,0],[0,1,0],[0,0,0]])
np.linalg.eigvals(A)
Out[8]:
In [9]:
det(A)
Out[9]:
In [15]:
def dt(kappa, dx):
return (0.5 * dx**2 / kappa)
In [25]:
kappa = 10**(-3)
dx = 1
day = 3600. * 24.
dt(kappa, dx)
Out[25]:
In [ ]: