@@ -509,7 +509,7 @@ def Run_Transport(lst,nps=[],code='mcnp6'):
509509 path = os .path .abspath (os .path .join (os .path .abspath (os .getcwd ()), os .pardir ))+ "/Results/Population/" + str (i )+ "/"
510510 sub .Popen ("cp {} {}" .format (path + "tmp/output/wwinp" ,path + "wwinp" ),cwd = path ,stdout = sub .PIPE ,shell = True )
511511 sub .Popen ("cp {} {}" .format (path + "tmp/output/inp_edits.txt" ,path + "inp_edits.txt" ), cwd = path ,stdout = sub .PIPE ,shell = True )
512- sub .Popen ("rm -rf {}tmp/*" .format (path ,i ),cwd = path ,stdout = sub .PIPE ,shell = True )
512+ sub .Popen ("rm -rf {}tmp/*" .format (path ,i ),cwd = path ,stderr = sub . STDOUT , stdout = sub .PIPE ,shell = True )
513513
514514 module_logger .info ('Total transport time was {} sec' .format (time .time () - start_time ))
515515
@@ -611,6 +611,30 @@ def Build_Batch(lst,tasks,code,suf=""):
611611
612612 return fname
613613
614+ #-------------------------------------------------------------------------------------------------------------#
615+ def to_Norm (spectrum ):
616+ """
617+ Normalizes a MCNP tallied flux
618+
619+ Parameters
620+ ==========
621+ spectrum : array
622+ The input flux spectrum
623+
624+ Optional
625+ ========
626+
627+ Returns
628+ =======
629+ result : array
630+ The output normalized differential flux spectrum
631+ """
632+
633+ flux = np .zeros (len (spectrum [:,0 ]))
634+ result = flux / np .sum (flux )
635+
636+ return result
637+
614638#-------------------------------------------------------------------------------------------------------------#
615639def to_NormDiff (spectrum ):
616640 """
@@ -639,25 +663,12 @@ def to_NormDiff(spectrum):
639663 # Calculate the differential flux
640664 diff [0 ]= (spectrum [0 ,1 ])/ (spectrum [0 ,0 ])
641665 for i in range (1 ,len (spectrum [:,0 ])):
642- diff [i ]= (spectrum [i ,1 ]+ spectrum [i - 1 ,1 ])/ (spectrum [i ,0 ]- spectrum [i - 1 ,0 ])
643-
644- # Calculate the integral of the differential flux using simpson's method
645- intdiff [0 ]= 0.5 * spectrum [0 ,0 ]* diff [0 ]
646- for i in range (1 ,len (spectrum [:,0 ])):
647- intdiff [i ]= 0.5 * (spectrum [i ,0 ]- spectrum [i - 1 ,0 ])* (diff [i ]+ diff [i - 1 ])
666+ diff [i ]= (spectrum [i ,1 ])/ (spectrum [i ,0 ]- spectrum [i - 1 ,0 ])
648667
649668 # Calculate the normalized differential flux
650- integral = np .sum (intdiff )
651- for i in range (0 ,len (spectrum [:,0 ])):
652- normdiff [i ]= diff [i ]/ integral
653-
654- # Calculate the integral of the normalized differential flux using simpson's method
655- result [0 ]= 0.5 * spectrum [0 ,0 ]* normdiff [0 ]
656- for i in range (1 ,len (spectrum [:,0 ])):
657- result [i ]= 0.5 * (spectrum [i ,0 ]- spectrum [i - 1 ,0 ])* (normdiff [i ]+ normdiff [i - 1 ])
669+ result = diff / np .sum (diff )
658670
659671 return result
660-
661672
662673#-------------------------------------------------------------------------------------------------------------#
663674def Uopt (c ,d ):
@@ -688,7 +699,7 @@ def Uopt(c,d):
688699#-------------------------------------------------------------------------------------------------------------#
689700def LeastSquares (c ,d ):
690701 """
691- Calculate the U-optimality
702+ Calculate the LeastSquares fit between two arrays
692703
693704 Parameters
694705 ==========
@@ -706,7 +717,7 @@ def LeastSquares(c,d):
706717 The least-squares design based fitness
707718 """
708719
709- assert len (c )== len (d ), "The length of the candidate and objective design must be equal in Uopt ."
720+ assert len (c )== len (d ), "The length of the candidate and objective design must be equal in LeastSquares ."
710721
711722 return np .sum ((d - c )** 2 )
712723
0 commit comments