i have the following code:
from math import *
from scipy.special import *
import matplotlib.pyplot as plt
import csv
## Definition der Parameter für Druckgleichung nach Rudnicki (1986) ##
q = 6.0/1000 # Fluidmenge pro Fläche und Zeit [l/s]
rhof = 1000 # Dichte Flüssigkeit [kg/m³]
lameu = 11.2*10**9 # Lamé-Parameter, undrained [Pa]
lame = 8.4*10**9 # Lamé-Parameter, drained [Pa]
pi # durch Pythonmodul "math" gegeben
alpha = 0.65 # Biot-Willis-Koeffizient
G = 8.4*10**9 # Schermodul [Pa]
k = 1.0e-15 # Permeabilität [m²] bzw. [Darcy]
eta = 0.001 # Viskosität des Fluids [Pa*s]
t = 1000*24*3600 # Zeit in [s]
## Beziehungen der Parameter untereinander ##
kappa = k/eta # Berechnung der Permeabilität nach Rudnicki (1986), [m³*s/kg]
print "kappa ist:",kappa # Ausgabe Permabilität
c = (kappa*(lameu-lame)*(lame+2*G))/((alpha**2)*(lameu+2*G)) # Berechnung der Diffusivität
print "c ist:",c # Ausgabe der Diffusivität
## Bereiche der Achsen in [m] ##
#def drange(start, stop, step):
# r = start
# while r <= stop:
# yield r
# r += step
xmin = 1
xmax = 20
ymin = 1
ymax = 20
## Druckberechnung um Bohrung ##
for x in range (xmin,xmax,1):
for y in range (ymin,ymax,1):
r = sqrt(x**2+y**2)
P = (q/(rhof*4*pi*kappa))*(expn(1,r**2/(4*c*t)))
z = P/1e6
#print x, " ", y, " ", z
For my ouput, i want to write my values of x,y and z in a csv file. It should look like e.g. each x-value in a cell within a single row and each y-value in a cell within the same column, so that one z-value can be shown for each x/y combination. It should look like this:
x x1 ...
y z(x,y) z(x1,y) ...
y1 z(x,y1) z(x1,y1) ...
... ... ...
I'm new to the csv module and not really getting used to it, especially how to set the values in the right places and when to use it (e.g. inside or after loops). Is this possible? Or can it only look like this (similar to my outcommented print):
x y z(x,y)
x y1 z(x,y1)
x y2 z(x,y2) ... ...
Sorry for this quite strange and ugly formatting, but i think you get my idea :)
Any help would - as always - be greatly appreciated!
pivariable? it seems not initialized.