Issue
Within my B.Sc. thesis I have to investigate the distribution of pore pressure and stresses around a fluid-injecting well. I try to solve this part by using Spyder, which seems to be the best interface for me because I have nearly zero experience in coding.
Although I worked through the most important Python and matplotlib documentation I cant find the solution for my problem.
First here's my code so far:
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 01 10:26:29 2014
@author: Alexander
"""
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from math import *
from scipy.special import *
import matplotlib.pyplot as plt
import numpy as np
q = 6.0/1000
rhof = 1000
lameu = 11.2*10**9
lame = 8.4*10**9
pi
alpha = 0.8
G = 8.4*10**9
k = 4*10**(-14)
eta = 0.001
t = 10*365*24*3600
kappa = k/eta
print "kappa ist:",kappa
c = ((kappa*(lameu-lame)*(lame+2*G))/((alpha**2)*(lameu+2*G)))
print "c ist:",c
xmin = -10
xmax = 10
ymin = -10
ymax = 10
X = np.arange(xmin,xmax,0.5)
Y = np.arange(ymin,ymax,0.5)
x, y = np.meshgrid(X, Y)
r=np.sqrt(x**2+y**2)
P=(q/(rhof*4*pi*kappa))*(expn(1,(r**2)/(4*c*t)))
print x,y
print P
z = P/1000000
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.jet, linewidth=0,
antialiased=True)
fig.colorbar(surf, shrink=0.5, aspect=5)
ax.set_xlim(xmin,xmax)
ax.set_ylim(ymin,ymax)
ax.set_title('Druckverteilung')
ax.set_xlabel('Distanz zu Well [m]')
ax.set_ylabel('Distanz zu Well [m]')
ax.set_zlabel('Druck in [MPa]')
plt.show()
I have two major questions:
After plotting, my colorbar only shows 1 color (blue) and I don't know why. I looked up for similar problems on this site, yet wasn't able to find a proper solution. How can I get this done?
Let's say I want to know the value of the pressure in my coordinates
x=5m
andy=2m
from my injection point (x,y=0). Is there a code to "grab" this value?
I will try to plot some stresses (e.g. normal stress and shear stress) around a borehole. Can I avoid the error I encountered within the pressure in future plots by simply using your suggested proposition of
z[z == np.inf] = np.nan
and modifying the plot_surface command? I ask because I'm not sure if I will have a value within inf
.
Solution
The color scale is all blue because one of you z values in inf. You can correct this first by setting the inf values in z to nan:
z[z == np.inf] = np.nan
And then telling plot_surface what range of values to plot using the vmin and vmax arguments:
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.jet, linewidth=0,
antialiased=True, vmin=np.nanmin(z), vmax=np.nanmax(z))
You can easily create a function to calculate z for a give x and y like this:
def calcZ(x,y):
r=np.sqrt(x**2+y**2)
P=(q/(rhof*4*pi*kappa))*(expn(1,(r**2)/(4*c*t)))
z = P/1000000
return z
Answered By - Molly
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.