Прошу прощения, не заметил, что count_l определен выше, весь код как раз не приводил, чтобы не запутать народ.
Вот объяснение по простому.
Есть таблица
x y N
0 0 2
1 0 3
0 1 4
1 1 5
Нужна таблица
x y N
0 0 2
1 0 3
2 0 2
3 0 3
0 1 4
1 1 5
2 1 4
3 1 5
0 2 2
1 2 3
2 2 2
3 2 3
0 3 4
1 3 5
2 3 4
3 3 5
Похоже, что выше я допустил ошибку с функциями N, пока сам не могу понять, как грамотно их продлить на всю область 10 на 10 ячеек.
Вот весь код(там много переменных, которые будут дальше задействованы):
#!/usr/bin/env python
# -*- coding: cp1251 -*-
import math as m
from numpy import *
from scipy.special import erf
math = m
materials = 1
if materials == 1:
comb = "Ti-6Al-4V SiC Al"
k1 = 1.2095
k2 = 183.8
k3 = 235
rho1 = 4429
rho2 = 3210
rho3 = 2700
c1 = 625.30
c2 = 750
c3 = 235
elif materials == 2:
comb = "SiC Ti-6Al-4V Al"
k1 = 183.8
k2 = 1.2095
k3 = 235
rho1 = 3210
rho2 = 4429
rho3 = 2700
c1 = 750
c2 = 625.30
c3 = 235
r1 = 0.3
r2 = 0.3001
l = 1
s1 = pi*r1**2
s2 = pi*r2**2 - s1
s3 = l**2 - (s1 + s2)
rho_c = rho1*c1*s1/l**2 + rho2*c2*s2/l**2 + rho3*c3*s3/l**2
rho_c = float(rho_c)
l_razm = 0.2
G_razm = 2
count_l = int(G_razm/l_razm)
T0 = 300
T1 = 900
t = 1800
k_eff_chisl = 132.066
k_eff_teor = 132.22
chi = k_eff_chisl/rho_c
file = open('C:\Program Files\Golden Software\Surfer8\coord1.dat', 'a')
file2 = open('C:\Program Files\Golden Software\Surfer8\coord2.dat', 'a')
file3 = open('C:\Program Files\Golden Software\Surfer8\Nfunkts.dat', 'a')
i = 0
for x in range (0 , 200*count_l + 1):
ks = str(i) + "\n"
file.writelines(ks)
i += 0.001
file.close()
data = open('C:\Program Files\Golden Software\Surfer8\coord1.dat', 'r')
lines = data.readlines()
data.close()
filex = open('C:\Program Files\Golden Software\Surfer8\coord1f.dat', 'a')
for cx in range (0, 200*count_l + 1):
for line in lines:
coords = line.split()
xs = float(coords[0])
kp = str(xs) + "\n"
filex.writelines(kp)
data = open('C:\Program Files\Golden Software\Surfer8\out.dat', 'r')
lines = data.readlines()
data.close()
for count in range (0, count_l**2):
for line in lines:
coords = line.split()
N = float(coords[2]) + 0.5
kp = str(N) + "\n"
file3.writelines(kp)
file3.close()
k = 0
for y in range (0, 200*count_l + 1):
for cy in range (0, 200*count_l + 1):
ky = str(k) + "\n"
file2.writelines(ky)
k += 0.001
file2.close()
file1 = open('C:\Program Files\Golden Software\Surfer8\coord1f.dat', 'r')
file2 = open('C:\Program Files\Golden Software\Surfer8\coord2.dat', 'r')
file3 = open('C:\Program Files\Golden Software\Surfer8\Nfunkts.dat', 'r')
lines_x = file1.readlines()
lines_y = file2.readlines()
lines_N = file3.readlines()
file1.close()
file2.close()
file3.close()
file4 = open('C:\Program Files\Golden Software\Surfer8\grafik.dat', 'a')
for x, y, N in zip(lines_x, lines_y, lines_N):
coordsx = x.split()
coordsy = y.split()
coordsN = N.split()
fin = str(float(coordsx[0])) + " " + str(float(coordsy[0])) + " " + str(float(coordsN[0])) + "\n"
file4.writelines(fin)
file4.close()