diff --git a/experiment/macro-problem/buckling_experiment/buckling_experiment.py b/experiment/macro-problem/buckling_experiment/buckling_experiment.py index 4697a5d5aa5cb4d4911fc6f1e9c46b9daf9f1b1a..4f21698710221c5d3112e83a064f1f24a660cff1 100644 --- a/experiment/macro-problem/buckling_experiment/buckling_experiment.py +++ b/experiment/macro-problem/buckling_experiment/buckling_experiment.py @@ -21,8 +21,14 @@ parameterSet = ParameterSet() parameterSet.resultPath = '/home/klaus/Desktop/Dune_bendIso/dune-microstructure/outputs_buckling_experiment' parameterSet.baseName= 'buckling_experiment' + + +""" + ----- MACRO-PROBLEM PARAMETERS: ----- +""" + ############################################# -# Grid parameters +# Macro-Grid parameters ############################################# # nX=8 # nY=8 @@ -106,8 +112,8 @@ parameterSet.writeVTK = 1 parameterSet.vtkwrite_analyticalSolution = 0 parameterSet.vtkWrite_analyticalSurfaceNormal = 0 -# The grid can be refined several times for a higher resolution in the VTK-file. -parameterSet.subsamplingRefinement = 2 +# # The grid can be refined several times for a higher resolution in the VTK-file. +# parameterSet.subsamplingRefinement = 2 # Write Dof-Vector to .txt-file parameterSet.writeDOFvector = 0 @@ -159,13 +165,6 @@ def dirichlet_indicator(x) : ############################################# # Initial iterate function ############################################# -# def f(x): -# return [x[0], x[1], 0] - -# def df(x): -# return ((1,0), -# (0,1), -# (0,0)) #Rotation: def R(beta): return [[math.cos(beta),0], @@ -183,6 +182,7 @@ def f(x): return [x[0], x[1], 0] +### Rotation angle (boundary condition). # beta = math.pi/4.0 beta= 0.025 # beta= math.pi/12.0 @@ -205,22 +205,6 @@ def df(x): -# def f(x): -# # a = 0.4 -# a = 1.4 -# if(x[0] <= -1.99): -# return [x[0] + a, x[1], 0] -# elif(x[0] >= 1.99): -# return [x[0] - a, x[1], 0] -# else: -# return [x[0], x[1], 0] - - -# def df(x): -# return ((1,0), -# (0,1), -# (0,0)) - fdf = (f, df) @@ -233,8 +217,6 @@ parameterSet.assemble_force_term = False def force(x): return [0, 0, 0] - - ############################################# # Analytical reference Solution ############################################# @@ -283,11 +265,14 @@ class GlobalMicrostructure: # Represents the local microstructure in Phase 1 class LocalMicrostructure_1: + + # prestrain parameter + rho = 0.0 + def __init__(self,macroPoint=[0,0]): # gamma = 1.0 # self.macroPoint = macroPoint self.gamma = 1.0 #in the future this might change depending on macroPoint. - self.phases = 2 #in the future this might change depending on macroPoint. #--- Define different material phases: # #- PHASE 1 @@ -312,7 +297,6 @@ class GlobalMicrostructure: # [0.8, 20.3, 0.0], # [0.0, 0.0, 19.3]]); - #--- Indicator function for material phases def indicatorFunction(self,x): fibreRadius = (1.0/4.0) @@ -327,10 +311,7 @@ class GlobalMicrostructure: #--- Define prestrain function for each phase (also works with non-constant values) def prestrain_phase1(self,x): - # return [[2, 0, 0], [0,2,0], [0,0,2]] - # rho = 0.0 - rho = 0.0 - return [[rho*1.0, 0, 0], [0,rho*1.0,0], [0,0,rho*1.0]] + return [[self.rho*1.0, 0, 0], [0,self.rho*1.0,0], [0,0,self.rho*1.0]] def prestrain_phase2(self,x): return [[0, 0, 0], [0,0,0], [0,0,0]] @@ -384,10 +365,15 @@ class GlobalMicrostructure: # return [[0, 0, 0], [0,0,0], [0,0,0]] + +""" + ----- MICRO-PROBLEM PARAMETERS: ----- +""" + parameterSet.printMicroOutput = 1 # Flag that allows to supress the output of the micro-problem. ############################################# -# Grid parameters +# Micro-Grid parameters ############################################# parameterSet.microGridLevel = 3 diff --git a/experiment/macro-problem/variableBC/cylindrical_2variableBC.py b/experiment/macro-problem/variableBC/cylindrical_2variableBC.py index c6efd1b064d1c9268b197f3233912d6090341eb0..fdec935ec4108a3df0e8dc7e46d7ecbdabb2db7c 100644 --- a/experiment/macro-problem/variableBC/cylindrical_2variableBC.py +++ b/experiment/macro-problem/variableBC/cylindrical_2variableBC.py @@ -9,7 +9,6 @@ class ParameterSet(dict): parameterSet = ParameterSet() - ############################################# # Paths ############################################# @@ -17,8 +16,13 @@ parameterSet.resultPath = '/home/klaus/Desktop/Dune_bendIso/dune-microstructure/ # parameterSet.outputPath = '/home/klaus/Desktop/Dune_bendIso/dune-microstructure/outputs_buckling_experiment' # This is currently still used in prestrainedMaterial parameterSet.baseName= 'cylindrical_2variableBC' + +""" + ----- MACRO-PROBLEM PARAMETERS: ----- +""" + ############################################# -# Grid parameters +# Macro-Grid parameters ############################################# nX=8 nY=8 @@ -96,7 +100,7 @@ parameterSet.vtkwrite_analyticalSolution = 0 parameterSet.vtkWrite_analyticalSurfaceNormal = 0 # The grid can be refined several times for a higher resolution in the VTK-file. -parameterSet.subsamplingRefinement = 2 +# parameterSet.subsamplingRefinement = 2 # Write Dof-Vector to .txt-file parameterSet.writeDOFvector = 0 @@ -104,17 +108,19 @@ parameterSet.writeDOFvector = 0 ############################################# # Dirichlet boundary indicator ############################################# +parameterSet.delta = 1.3 +print('parameterSet.delta:', parameterSet.delta) + def dirichlet_indicator(x) : - delta = 1.3 + # length of the clamped boundary-segment + delta = parameterSet.delta + print('delta:', delta) # if( (x[0] < -0.99) and (abs(x[1]) <(delta/2.0) )): if( (x[0] < -0.99) and (abs(x[1]) <=(delta/2.0) )): return True else: return False - - - ############################################# # Microstructure ############################################ @@ -131,66 +137,8 @@ def df(x): return ((1,0), (0,1), (0,0)) -# #Rotation: -# def R(beta): -# return [[math.cos(beta),0], -# [0,1], -# [-math.sin(beta),0]] - - -# def f(x): -# a = 0.5 -# if(x[0] <= 0.01): -# return [x[0], x[1], 0] -# elif(x[0] >= 3.99): -# return [x[0] - a, x[1], 0] -# else: -# return [x[0], x[1], 0] - - -# # beta = math.pi/4.0 -# beta= 0.05 -# # beta= math.pi/12.0 -# # beta= 0.10 -# # beta = 0 - -# def df(x): -# a = 0.5 -# if(x[0] <= 0.01): -# # return R(-1.0*beta) -# return R(beta) -# elif(x[0] >= 3.99): -# # return R(beta) -# return R(-1.0*beta) -# else: -# return ((1,0), -# (0,1), -# (0,0)) - - - - -# def f(x): -# # a = 0.4 -# a = 1.4 -# if(x[0] <= -1.99): -# return [x[0] + a, x[1], 0] -# elif(x[0] >= 1.99): -# return [x[0] - a, x[1], 0] -# else: -# return [x[0], x[1], 0] - - -# def df(x): -# return ((1,0), -# (0,1), -# (0,0)) - - fdf = (f, df) - - ############################################# # Force ############################################ @@ -199,25 +147,6 @@ parameterSet.assemble_force_term = False def force(x): return [0, 0, 0] - - -############################################# -# Analytical reference Solution -############################################# -# def f(x): -# return [x[0], x[1], 0] -# -# -# def df(x): -# return ((1,0), -# (0,1), -# (0,0)) -# -# -# fdf = (f, df) - - - ##################### MICROSCALE PROBLEM #################### # parameterSet.prestrainFlag = True #deprecated @@ -270,6 +199,11 @@ class GlobalMicrostructure: # Represents the local microstructure in Phase 1 class LocalMicrostructure_1: + + rho = 0.95 + # rho = 0.75 + # rho = 0.33 + def __init__(self,macroPoint=[0,0]): # self.macroPoint = macroPoint self.gamma = 1.0 #in the future this might change depending on macroPoint. @@ -314,13 +248,9 @@ class GlobalMicrostructure: def prestrain_phase1(self,x): return [[1.0, 0, 0], [0,1.0,0], [0,0,1.0]] - # prestrained fibre in bottom layer , e1-aligned def prestrain_phase2(self,x): - rho = 0.95 - # rho = 0.75 - # rho = 0.33 - return [[rho*1.0, 0, 0], [0,rho*1.0,0], [0,0,rho*1.0]] + return [[self.rho*1.0, 0, 0], [0,self.rho*1.0,0], [0,0,self.rho*1.0]] def prestrain_phase3(self,x): return [[0, 0, 0], [0,0,0], [0,0,0]] @@ -372,13 +302,16 @@ class GlobalMicrostructure: # return [[0, 0, 0], [0,0,0], [0,0,0]] - +""" + ----- MICRO-PROBLEM PARAMETERS: ----- +""" parameterSet.printMicroOutput = 1 # Flag that allows to supress the output of the micro-problem. ############################################# -# Grid parameters +# Micro-Grid parameters ############################################# -parameterSet.microGridLevel = 5 +parameterSet.microGridLevel = 2 #5 + ############################################# # Assembly options diff --git a/testsuite/macro-problem-testsuite.py b/testsuite/macro-problem-testsuite.py index 64db717050f0f935bf569450fcf48d5bf1536884..2bc1e5f867c46aa00530e92dcf4f1acaf942b735 100644 --- a/testsuite/macro-problem-testsuite.py +++ b/testsuite/macro-problem-testsuite.py @@ -28,7 +28,7 @@ create_outputTable = False #TODO: This needs to be adjustet with the ParameterN # 1. Experiment 2. ExperimentPathExtension 3. MacroGridLevels, 4. Executable 5.(additional) parameterArray: [["ParameterName", ParameterValue], ...] scenarios = [ # ["buckling_experiment" , "/buckling_experiment", [3,3], "/macro-problem" , [["rho", [0,1,2,3,4,5]]] ], - ["buckling_experiment" , "/macro-problem/buckling_experiment", [2,2] , "/macro-problem" , [["rho", [1.0]]] ], + ["buckling_experiment" , "/macro-problem/buckling_experiment", [2,2] , "/macro-problem" , [["rho", [2.0]]] ], ["buckling_experiment_rho_0" , "/macro-problem/buckling_experiment", list(range(3,7,1)), "/macro-problem" , [] ], ["buckling_experiment_rho_1" , "/macro-problem/buckling_experiment", list(range(3,7,1)), "/macro-problem" , [] ], ["cylindrical_2variableBC_delta025" , "/macro-problem/variableBC", [2], "/macro-problem" , [] ], #4 @@ -137,6 +137,9 @@ else : instrumentedPath = resultPath + "/instrumented" executablePath = modulePath + '/build-cmake/src' + + tmp_ExpPath = "/home/klaus" + # try: # os.mkdir(resultPath) # os.mkdir(instrumentedPath) @@ -145,6 +148,7 @@ else : try: os.mkdir(resultPath) os.mkdir(instrumentedPath) + os.mkdir(tmp_ExpPath) except OSError as error: print(error) @@ -242,13 +246,42 @@ else: parameterName = parameterArray[i][0] parameterValue = parameterArray[i][1][v] + if CONTAINER: + # New Version: + print('WE ARE NOW HERE.') + original_path = pythonPath + "/" + scenarios[slurm_array_task_id][0] +'.py' + + # tmp_ExpPath="/home/klaus" + # Create writable directory if it doesn't exist + os.makedirs(tmp_ExpPath, exist_ok=True) + + + # Generate new path in writable location + filename = os.path.basename(original_path) + new_path = os.path.join(tmp_ExpPath, filename) + + print('original_path:',original_path) + print('filename:',filename) + print('new_path:',new_path) + + # Copy original file to writable location + shutil.copy2(original_path, new_path) + + + new_file = os.path.join(tmp_ExpPath, os.path.basename(pythonPath + "/" + scenarios[slurm_array_task_id][0])) + print('new_file:',new_file) + + # print('...change input parameter:' , parameterName) + # SetParameterMaterialFunction(new_file, parameterName , parameterValue) + SetParameterMaterialFunction(tmp_ExpPath + "/" + scenarios[slurm_array_task_id][0], parameterName , parameterValue) + print('CHANGED PARAMETERS.') + else: + ## Alternative version: actually changing the parset file.. + # Change Parameters: + print('...change input parameter:' , parameterName) + SetParameterMaterialFunction(pythonPath + "/" + scenarios[slurm_array_task_id][0], parameterName , parameterValue) - print('WE ARE NOW HERE.') - ## Alternative version: actually changing the parset file.. - # Change Parameters: - print('...change input parameter:' , parameterName) - SetParameterMaterialFunction(pythonPath + "/" + scenarios[slurm_array_task_id][0], parameterName , parameterValue) """" @@ -280,16 +313,28 @@ else: # testArray = [ " -rho " + str(8.0), " -beta " + str(0.10) ] - # start_time = time.time() - p = subprocess.Popen(executable + " " + pythonPath + " " + parameterFile - + " -macroGridLevel " + str(macroGridLevel) - + " -resultPath " + str(resultPath) - + " -baseName " + str(baseName) - + " -instrumentedPath " + str(instrumentedPath) - + " -conforming_DiscreteJacobian " + str(conforming_DiscreteJacobian) - + " -instrumented " + str(INSTRUMENTED) - # + " -" + parameterName + " " + str(parameterValue) - + " | tee " + LOGFILE, shell=True) + if CONTAINER: + # start_time = time.time() + p = subprocess.Popen(executable + " " + tmp_ExpPath + " " + scenarios[slurm_array_task_id][0] + + " -macroGridLevel " + str(macroGridLevel) + + " -resultPath " + str(resultPath) + + " -baseName " + str(baseName) + + " -instrumentedPath " + str(instrumentedPath) + + " -conforming_DiscreteJacobian " + str(conforming_DiscreteJacobian) + + " -instrumented " + str(INSTRUMENTED) + # + " -" + parameterName + " " + str(parameterValue) + + " | tee " + LOGFILE, shell=True) + else : + # start_time = time.time() + p = subprocess.Popen(executable + " " + pythonPath + " " + parameterFile + + " -macroGridLevel " + str(macroGridLevel) + + " -resultPath " + str(resultPath) + + " -baseName " + str(baseName) + + " -instrumentedPath " + str(instrumentedPath) + + " -conforming_DiscreteJacobian " + str(conforming_DiscreteJacobian) + + " -instrumented " + str(INSTRUMENTED) + # + " -" + parameterName + " " + str(parameterValue) + + " | tee " + LOGFILE, shell=True) p.wait() # wait # print("--- %s seconds ---" % (time.time() - start_time))