indents wrong in fortran, seeds_fromDistribution bugfix and using ASCII table facilities

This commit is contained in:
Martin Diehl 2015-09-20 21:03:10 +00:00
parent 78809c8114
commit 42ac7902f7
3 changed files with 16 additions and 19 deletions

View File

@ -417,8 +417,8 @@ subroutine AL_formResidual(in,x_scal,f_scal,dummy,ierr)
if (iand(debug_level(debug_spectral),debug_spectralRotation) /= 0) &
write(6,'(/,a,/,3(3(f12.7,1x)/))',advance='no') ' deformation gradient aim (lab) =', &
math_transpose33(math_rotate_backward33(F_aim,params%rotation_BC))
write(6,'(/,a,/,3(3(f12.7,1x)/))',advance='no') ' deformation gradient aim =', &
math_transpose33(F_aim)
write(6,'(/,a,/,3(3(f12.7,1x)/))',advance='no') ' deformation gradient aim =', &
math_transpose33(F_aim)
flush(6)
endif
endif newIteration
@ -669,8 +669,7 @@ subroutine AL_forward(guess,timeinc,timeinc_old,loadCaseTime,F_BC,P_BC,rotation_
Fdot = Utilities_calculateRate(math_rotate_backward33(f_aimDot,rotation_BC), &
timeinc_old,guess,F_lastInc,reshape(F,[3,3,grid(1),grid(2),grid3]))
F_lambdaDot = Utilities_calculateRate(math_rotate_backward33(f_aimDot,rotation_BC), &
timeinc_old,guess,F_lambda_lastInc,reshape(F_lambda,[3,3,grid(1), &
grid(2),grid3]))
timeinc_old,guess,F_lambda_lastInc,reshape(F_lambda,[3,3,grid(1),grid(2),grid3]))
F_lastInc = reshape(F, [3,3,grid(1),grid(2),grid3])
F_lambda_lastInc = reshape(F_lambda,[3,3,grid(1),grid(2),grid3])
endif

View File

@ -355,7 +355,7 @@ subroutine BasicPETSC_formResidual(in,x_scal,f_scal,dummy,ierr)
math_transpose33(math_rotate_backward33(F_aim,params%rotation_BC))
write(6,'(/,a,/,3(3(f12.7,1x)/))',advance='no') ' deformation gradient aim =', &
math_transpose33(F_aim)
flush(6)
flush(6)
endif
endif newIteration

View File

@ -76,6 +76,7 @@ class myThread (threading.Thread):
s.release()
if randReset: # new direction because current one led to worse fit
randReset = False
NmoveGrains = random.randrange(1,maxSeeds)
@ -97,16 +98,17 @@ class myThread (threading.Thread):
perturbedSeedsTable.head_write()
outputAlive=True
ms = 1
i = 0
while outputAlive and perturbedSeedsTable.data_read(): # perturbe selected microstructure
if ms in selectedMs:
direction+=direction
newCoords=np.array(tuple(map(float,perturbedSeedsTable.data[0:3]))+direction[i])
newCoords=np.where(newCoords>=1.0,newCoords-1.0,newCoords) # ensure that the seeds remain in the box (move one side out, other side in)
newCoords=np.where(newCoords <0.0,newCoords+1.0,newCoords)
perturbedSeedsTable.data[0:3]=[format(f, '8.6f') for f in newCoords]
direction[i]*=2.
i+= 1
ms+=1
perturbedSeedsTable.data_write()
#--- do tesselation with perturbed seed file ----------------------------------------------------------
perturbedGeomVFile.close()
perturbedGeomVFile = StringIO()
@ -114,8 +116,9 @@ class myThread (threading.Thread):
perturbedGeomVFile.write(execute('geom_fromVoronoiTessellation '+
' -g '+' '.join(map(str, options.grid)),streamIn=perturbedSeedsVFile)[0])
perturbedGeomVFile.reset()
#--- evaluate current seeds file ----------------------------------------------------------------------
perturbedGeomTable = damask.ASCIItable(perturbedGeomVFile,labeled=False,readonly=True)
perturbedGeomTable = damask.ASCIItable(perturbedGeomVFile,None,labeled=False,readonly=True)
perturbedGeomTable.head_read()
for i in perturbedGeomTable.info:
if i.startswith('microstructures'): myNmicrostructures = int(i.split('\t')[1])
@ -233,16 +236,12 @@ points = float(reduce(mul,options.grid))
# ----------- calculate target distribution and bin edges
targetGeomFile = os.path.splitext(os.path.basename(options.target))[0]+'.geom'
targetGeomTable = damask.ASCIItable(targetGeomFile,labeled=False,readonly=True)
targetGeomTable = damask.ASCIItable(targetGeomFile,None,labeled=False,readonly=True)
targetGeomTable.head_read()
for i in targetGeomTable.info:
if i.startswith('microstructures'): nMicrostructures = int(i.split()[1])
if i.startswith('grid'): targetPoints = int(np.array(map(float,i.split()[2:7:2])).prod())
targetGeomTable.data_readArray()
targetVolFrac = np.bincount(targetGeomTable.data.astype(int).ravel())[1:nMicrostructures+1]/targetPoints
info,devNull = targetGeomTable.head_getGeom()
nMicrostructures = info['microstructures']
targetVolFrac = np.bincount(targetGeomTable.microstructure_read(info['grid']))[1:nMicrostructures+1]/\
float(info['grid'].prod())
target=[]
for i in xrange(1,nMicrostructures+1):
targetHist,targetBins = np.histogram(targetVolFrac,bins=i) #bin boundaries
@ -266,7 +265,7 @@ initialGeomVFile = StringIO()
initialGeomVFile.write(execute('geom_fromVoronoiTessellation '+
' -g '+' '.join(map(str, options.grid)),bestSeedsVFile)[0])
initialGeomVFile.reset()
initialGeomTable = damask.ASCIItable(initialGeomVFile,labeled=False,readonly=True)
initialGeomTable = damask.ASCIItable(initialGeomVFile,None,labeled=False,readonly=True)
initialGeomTable.head_read()
info,devNull = initialGeomTable.head_getGeom()
@ -296,7 +295,6 @@ if match >0: print 'Stage %i cleared'%match
sys.stdout.flush()
initialGeomVFile.close()
# start mulithreaded monte carlo simulation
threads=[]
s=threading.Semaphore(1)