indents wrong in fortran, seeds_fromDistribution bugfix and using ASCII table facilities
This commit is contained in:
parent
78809c8114
commit
42ac7902f7
|
@ -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), &
|
Fdot = Utilities_calculateRate(math_rotate_backward33(f_aimDot,rotation_BC), &
|
||||||
timeinc_old,guess,F_lastInc,reshape(F,[3,3,grid(1),grid(2),grid3]))
|
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), &
|
F_lambdaDot = Utilities_calculateRate(math_rotate_backward33(f_aimDot,rotation_BC), &
|
||||||
timeinc_old,guess,F_lambda_lastInc,reshape(F_lambda,[3,3,grid(1), &
|
timeinc_old,guess,F_lambda_lastInc,reshape(F_lambda,[3,3,grid(1),grid(2),grid3]))
|
||||||
grid(2),grid3]))
|
|
||||||
F_lastInc = reshape(F, [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])
|
F_lambda_lastInc = reshape(F_lambda,[3,3,grid(1),grid(2),grid3])
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -76,6 +76,7 @@ class myThread (threading.Thread):
|
||||||
s.release()
|
s.release()
|
||||||
|
|
||||||
if randReset: # new direction because current one led to worse fit
|
if randReset: # new direction because current one led to worse fit
|
||||||
|
|
||||||
randReset = False
|
randReset = False
|
||||||
|
|
||||||
NmoveGrains = random.randrange(1,maxSeeds)
|
NmoveGrains = random.randrange(1,maxSeeds)
|
||||||
|
@ -97,16 +98,17 @@ class myThread (threading.Thread):
|
||||||
perturbedSeedsTable.head_write()
|
perturbedSeedsTable.head_write()
|
||||||
outputAlive=True
|
outputAlive=True
|
||||||
ms = 1
|
ms = 1
|
||||||
|
i = 0
|
||||||
while outputAlive and perturbedSeedsTable.data_read(): # perturbe selected microstructure
|
while outputAlive and perturbedSeedsTable.data_read(): # perturbe selected microstructure
|
||||||
if ms in selectedMs:
|
if ms in selectedMs:
|
||||||
direction+=direction
|
|
||||||
newCoords=np.array(tuple(map(float,perturbedSeedsTable.data[0:3]))+direction[i])
|
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>=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)
|
newCoords=np.where(newCoords <0.0,newCoords+1.0,newCoords)
|
||||||
perturbedSeedsTable.data[0:3]=[format(f, '8.6f') for f in newCoords]
|
perturbedSeedsTable.data[0:3]=[format(f, '8.6f') for f in newCoords]
|
||||||
|
direction[i]*=2.
|
||||||
|
i+= 1
|
||||||
ms+=1
|
ms+=1
|
||||||
perturbedSeedsTable.data_write()
|
perturbedSeedsTable.data_write()
|
||||||
|
|
||||||
#--- do tesselation with perturbed seed file ----------------------------------------------------------
|
#--- do tesselation with perturbed seed file ----------------------------------------------------------
|
||||||
perturbedGeomVFile.close()
|
perturbedGeomVFile.close()
|
||||||
perturbedGeomVFile = StringIO()
|
perturbedGeomVFile = StringIO()
|
||||||
|
@ -114,8 +116,9 @@ class myThread (threading.Thread):
|
||||||
perturbedGeomVFile.write(execute('geom_fromVoronoiTessellation '+
|
perturbedGeomVFile.write(execute('geom_fromVoronoiTessellation '+
|
||||||
' -g '+' '.join(map(str, options.grid)),streamIn=perturbedSeedsVFile)[0])
|
' -g '+' '.join(map(str, options.grid)),streamIn=perturbedSeedsVFile)[0])
|
||||||
perturbedGeomVFile.reset()
|
perturbedGeomVFile.reset()
|
||||||
|
|
||||||
#--- evaluate current seeds file ----------------------------------------------------------------------
|
#--- evaluate current seeds file ----------------------------------------------------------------------
|
||||||
perturbedGeomTable = damask.ASCIItable(perturbedGeomVFile,labeled=False,readonly=True)
|
perturbedGeomTable = damask.ASCIItable(perturbedGeomVFile,None,labeled=False,readonly=True)
|
||||||
perturbedGeomTable.head_read()
|
perturbedGeomTable.head_read()
|
||||||
for i in perturbedGeomTable.info:
|
for i in perturbedGeomTable.info:
|
||||||
if i.startswith('microstructures'): myNmicrostructures = int(i.split('\t')[1])
|
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
|
# ----------- calculate target distribution and bin edges
|
||||||
targetGeomFile = os.path.splitext(os.path.basename(options.target))[0]+'.geom'
|
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()
|
targetGeomTable.head_read()
|
||||||
|
info,devNull = targetGeomTable.head_getGeom()
|
||||||
for i in targetGeomTable.info:
|
nMicrostructures = info['microstructures']
|
||||||
if i.startswith('microstructures'): nMicrostructures = int(i.split()[1])
|
targetVolFrac = np.bincount(targetGeomTable.microstructure_read(info['grid']))[1:nMicrostructures+1]/\
|
||||||
if i.startswith('grid'): targetPoints = int(np.array(map(float,i.split()[2:7:2])).prod())
|
float(info['grid'].prod())
|
||||||
|
|
||||||
targetGeomTable.data_readArray()
|
|
||||||
|
|
||||||
targetVolFrac = np.bincount(targetGeomTable.data.astype(int).ravel())[1:nMicrostructures+1]/targetPoints
|
|
||||||
target=[]
|
target=[]
|
||||||
for i in xrange(1,nMicrostructures+1):
|
for i in xrange(1,nMicrostructures+1):
|
||||||
targetHist,targetBins = np.histogram(targetVolFrac,bins=i) #bin boundaries
|
targetHist,targetBins = np.histogram(targetVolFrac,bins=i) #bin boundaries
|
||||||
|
@ -266,7 +265,7 @@ initialGeomVFile = StringIO()
|
||||||
initialGeomVFile.write(execute('geom_fromVoronoiTessellation '+
|
initialGeomVFile.write(execute('geom_fromVoronoiTessellation '+
|
||||||
' -g '+' '.join(map(str, options.grid)),bestSeedsVFile)[0])
|
' -g '+' '.join(map(str, options.grid)),bestSeedsVFile)[0])
|
||||||
initialGeomVFile.reset()
|
initialGeomVFile.reset()
|
||||||
initialGeomTable = damask.ASCIItable(initialGeomVFile,labeled=False,readonly=True)
|
initialGeomTable = damask.ASCIItable(initialGeomVFile,None,labeled=False,readonly=True)
|
||||||
initialGeomTable.head_read()
|
initialGeomTable.head_read()
|
||||||
info,devNull = initialGeomTable.head_getGeom()
|
info,devNull = initialGeomTable.head_getGeom()
|
||||||
|
|
||||||
|
@ -296,7 +295,6 @@ if match >0: print 'Stage %i cleared'%match
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
initialGeomVFile.close()
|
initialGeomVFile.close()
|
||||||
|
|
||||||
|
|
||||||
# start mulithreaded monte carlo simulation
|
# start mulithreaded monte carlo simulation
|
||||||
threads=[]
|
threads=[]
|
||||||
s=threading.Semaphore(1)
|
s=threading.Semaphore(1)
|
||||||
|
|
Loading…
Reference in New Issue