execute.py 2.57 KB
Newer Older
Jeremy BLEYER's avatar
Jeremy BLEYER committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
import numpy as np
import h5py
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from Reference import reference
from Homog_hierar import homog_hierar
from inclusions import image_init,image_augmente
import os


N=256
D=0.03


C=[0. for i in range(2)]

E=[0.,0.]
nu=[0.,0.]

E[0]=1
nu[0]=0.2
nu[1]=0.2


for c in [100,0.01]:
    print("contraste "+str(c)+'\n')
    os.system("mkdir c="+str(c))
    E[1]=1/c
    for i in range(2):
        C[i]=np.array([[(1-nu[i])*E[i]/(1-2*nu[i])/(1+nu[i]),
                        nu[i]*E[i]/(1-2*nu[i])/(1+nu[i]),0.],
                       [nu[i]*E[i]/(1-2*nu[i])/(1+nu[i]),(1-nu[i])*E[i]/(1-2*nu[i])/(1+nu[i]),0.],
                       [0.,0.,E[i]/(1+nu[i])]])

    for i in range(10):
        os.system("mkdir c="+str(c)+"/ech="+str(i))
        print("échantillon "+str(i)+'\n')
        fi = h5py.File("c="+str(c)+"/c="+str(c)+"ech"+str(i)+".hdf5","a")
        im,f0=image_init(N,D,0.1)
        fi['images']=np.zeros((8,N,N))
        fi['fractions']=np.zeros((8,))
        fi['ChomEF']=np.zeros((8,3,3))
        fi['CVoigt']=np.zeros((8,3,3))
        fi['ChomHH']=np.zeros((8,10,2,3,3))
        fi['EpsHH']=np.zeros((8,10,N,N,3,3))

        for j,f in enumerate([0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8]):
            os.system("mkdir c="+str(c)+"/ech="+str(i)+"/frac="+str(f))
            print("fraction volumique "+str(f)+'\n')
            if f!=0.1:
                f1=image_augmente(im,D,f)
            else:
                f1=f0
            # plt.figure()
            # plt.imshow(im[:,:],origin='lower')
            # plt.show()
            # plt.close()
            fi['images'][j]=im
            fi['fractions'][j]=f1

            tC=np.array([[C[0] for ii in range(N)] for jj in range(N)])
            for ii in range(N):
                for jj in range(N):
                    if im[ii,jj]==1:
                        tC[ii,jj]=C[1]

68
            ChomEF,CVoigt = reference(tC,256,c,i,f)
Jeremy BLEYER's avatar
Jeremy BLEYER committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
            fi['ChomEF'][j]=ChomEF
            fi['CVoigt'][j]=CVoigt

            ChomHH_list,tA_list=homog_hierar(tC,CVoigt)
            l=len(ChomHH_list)
            if l<10:
                for k in range(l):
                    fi['ChomHH'][j,k]=ChomHH_list[k]
                    fi['EpsHH'][j,k]=tA_list[k]
                for k in range(l,10):
                    fi['ChomHH'][j,k]=ChomHH_list[l-1]
                    fi['EpsHH'][j,k]=tA_list[l-1]
            else:
                for k in range(10):
                    fi['ChomHH'][j,k]=ChomHH_list[k]
                    fi['EpsHH'][j,k]=tA_list[k]