Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-microstructure-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klaus Böhnlein
dune-microstructure-backup
Commits
b5835d1c
Commit
b5835d1c
authored
3 years ago
by
Klaus Böhnlein
Browse files
Options
Downloads
Patches
Plain Diff
Add method to set Parameters in parsets
parent
5d579efc
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
inputs/cellsolver.parset
+27
-76
27 additions, 76 deletions
inputs/cellsolver.parset
inputs/computeMuGamma.parset
+27
-5
27 additions, 5 deletions
inputs/computeMuGamma.parset
src/HelperFunctions.py
+55
-22
55 additions, 22 deletions
src/HelperFunctions.py
src/makePlot.py
+22
-9
22 additions, 9 deletions
src/makePlot.py
with
131 additions
and
112 deletions
inputs/cellsolver.parset
+
27
−
76
View file @
b5835d1c
# --- Parameter File as Input for 'Cell-Problem'
#
# NOTE: define variables without whitespaces in between! i.e. : gamma=1.0 instead of gamma = 1.0
# since otherwise these cant be read from other Files!
# --------------------------------------------------------
#path for logfile
...
...
@@ -13,50 +20,18 @@
#############################################
# Cell Domain
#############################################
# Domain 1: (-1/2, 1/2)^3 , Domain 2 : [0,1)^2 x (-1/2, 1/2)
cellDomain = 1
#############################################
# Grid parameters
#############################################
#######################################################################
## numLevels : Number of Levels on which solution is computed. starting with a 2x2x2 cube mesh.
## {start,finish} computes on all grid from 2^(start) to 2^finish refinement
########################################################################
#numLevels = 1 3 # computes all levels from first to second entry
numLevels = 3 3 # computes all levels from first to second entry
#numLevels = 1 6
nElements = 32 32
#Elements_Cell = 20 20 20 # number elements in each direction (y1 y2 x3)
#nElements_Cell = 30 30 30
#nElements_Cell = 30 30 30
#nElements_Cell = 50 50 50
#nElements_Cell = 100 100 2
#nElements_Cell = 100 100 100 // does not work
#nElements_Cell = 10 10 10
#nElements_Cell = 2 2 2
#nElements_Cell = 4 4 4
#nElements_Cell = 8 8 8
#nElements_Cell = 16 16 16
#nElements_Cell = 32 32 32
#nElements_Cell = 64 64 64
gamma=0.25
#gamma=50.0
gamma=1.0
#gamma=2.5
#############################################
# Material parameters
#############################################
...
...
@@ -66,17 +41,15 @@ write_materialFunctions = true # VTK mu-functions , lambda-functions
beta = 2.0 # ratio between material parameters mu1 & mu2 .... beta = 1.0 corresponds to homogeneous case
mu1=10.0
lambda1=10.0
#lambda1 = 20.0
#lambda1 = 20.0
#lambda1 = 5.0
#mu1=1000.0
#### material_implementation("analytical_Example") ?
lambda1=10.0
#material_prestrain_imp= "analytical_Example"
material_prestrain_imp ="isotropic_bilayer"
#### material_implementation("analytical_Example") ?
material_prestrain_imp= "analytical_Example"
#material_prestrain_imp ="isotropic_bilayer"
#material_prestrain_imp= "circle_fiber" #TEST
...
...
@@ -89,8 +62,10 @@ material_prestrain_imp ="isotropic_bilayer"
write_prestrainFunctions = true # VTK norm of B ,
rho1 = 1.0
alpha = 5.0 # ratio between prestrain parameters rho1 & rho2
alpha = 2.0 # ratio between prestrain parameters rho1 & rho2
theta = 0.25
#theta = 0.3 # volume fraction #default = 1.0/4.0
#theta = 0.25 # volume fraction
#theta = 0.75 # volume fraction
...
...
@@ -111,32 +86,6 @@ height = 1.0
# Prestrain Types:
#1 Isotropic Pressure
# Func2Tensor B1_ = [this] (const Domain& x) { // ISOTROPIC PRESSURE
# if (abs(x[0]) > (theta/2) && x[2] > 0)
# return MatrixRT{{p1, 0.0 , 0.0}, {0.0, p1, 0.0}, {0.0, 0.0, p1}};
# if (abs(x[0]) < (theta/2) && x[2] < 0)
# return MatrixRT{{p2, 0.0 , 0.0}, {0.0, p2, 0.0}, {0.0, 0.0, p2}};
# else
# return MatrixRT{{0.0, 0.0 , 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
# };
#############################################
# Assembly options
#############################################
set_IntegralZero = true
#set_IntegralZero = false
#arbitraryLocalIndex = 7
#arbitraryElementNumber = 3
#arbitraryLocalIndex = 0
#arbitraryElementNumber = 0
#############################################
# Solver Type
...
...
@@ -145,15 +94,8 @@ set_IntegralZero = true
Solvertype = 1
#write_corrector_phi1 = false
#write_corrector_phi2 = false
#write_corrector_phi3 = false
#write_corrector_phi1 = true
#write_corrector_phi2 = true
#write_corrector_phi3 = true
write_L2Error = true
#write_IntegralMean = true
#############################################
# Define Analytic Solutions
...
...
@@ -168,3 +110,12 @@ write_L2Error = true
)*mu2)
This diff is collapsed.
Click to expand it.
inputs/computeMuGamma.parset
+
27
−
5
View file @
b5835d1c
# --- Parameter File as Input for 'Compute_MuGamma'
#
# NOTE: define variables without whitespaces in between! i.e. : gamma=1.0 instead of gamma = 1.0
# since otherwise these cant be read from other Files!
# --------------------------------------------------------
#path for logfile
#outputPath = "../../outputs/output.txt"
...
...
@@ -21,17 +29,19 @@
nElements = 32 32
gamma=0.5
gamma=0.25
#############################################
# Material parameters
#############################################
write_materialFunctions = true # VTK mu-functions , lambda-functions
beta
= 2.0 # ratio between material parameters mu1 & mu2 .... beta = 1.0 corresponds to homogeneous case
beta
=2.0
mu1=10.0
#mu1=1000.0
#lambda1=10.0
#lambda1 = 20.0
...
...
@@ -53,8 +63,11 @@ material_prestrain_imp= "analytical_Example"
write_prestrainFunctions = true # VTK norm of B ,
rho1 = 1.0
alpha = 2.0 # ratio between prestrain parameters rho1 & rho2
rho1=1.0
alpha=2.0
theta=0.2
#theta = 0.3 # volume fraction #default = 1.0/4.0
#theta = 0.25 # volume fraction
...
...
@@ -100,3 +113,12 @@ Solvertype = 1
)*mu2)
This diff is collapsed.
Click to expand it.
src/HelperFunctions.py
+
55
−
22
View file @
b5835d1c
...
...
@@ -40,18 +40,49 @@ def ReadEffectiveQuantities(QFilePath = os.path.dirname(os.getcwd()) + '/outputs
def
SetParametersCellProblem
(
alpha
,
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
=
os
.
path
.
dirname
(
os
.
getcwd
())
+
"
/inputs/computeMuGamma.parset
"
):
with
open
(
InputFilePath
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^alpha=.*
'
,
'
alpha=
'
+
str
(
alpha
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^beta=.*
'
,
'
beta=
'
+
str
(
beta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^theta=.*
'
,
'
theta=
'
+
str
(
theta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^gamma=.*
'
,
'
gamma=
'
+
str
(
gamma
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^mu1=.*
'
,
'
mu1=
'
+
str
(
mu1
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^rho1=.*
'
,
'
rho1=
'
+
str
(
rho1
),
filedata
)
f
=
open
(
InputFilePath
,
'
w
'
)
f
.
write
(
filedata
)
f
.
close
()
#TODO combine these...
def
SetParametersComputeMuGamma
(
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
=
os
.
path
.
dirname
(
os
.
getcwd
())
+
"
/inputs/computeMuGamma.parset
"
):
with
open
(
InputFilePath
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^beta=.*
'
,
'
beta=
'
+
str
(
beta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^theta=.*
'
,
'
theta=
'
+
str
(
theta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^gamma=.*
'
,
'
gamma=
'
+
str
(
gamma
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^mu1=.*
'
,
'
mu1=
'
+
str
(
mu1
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^rho1=.*
'
,
'
rho1=
'
+
str
(
rho1
),
filedata
)
f
=
open
(
InputFilePath
,
'
w
'
)
f
.
write
(
filedata
)
f
.
close
()
def
RunCellProblem
(
alpha
,
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
=
os
.
path
.
dirname
(
os
.
getcwd
())
+
"
/inputs/computeMuGamma.parset
"
):
with
open
(
InputFilePath
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^gamma=.*
'
,
'
gamma=
'
+
str
(
gamma
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^alpha=.*
'
,
'
alpha=
'
+
str
(
alpha
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^beta=.*
'
,
'
beta=
'
+
str
(
beta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^theta=.*
'
,
'
theta=
'
+
str
(
theta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^mu1=.*
'
,
'
mu1=
'
+
str
(
mu1
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^rho1=.*
'
,
'
rho1=
'
+
str
(
rho1
),
filedata
)
f
=
open
(
InputFilePath
,
'
w
'
)
f
.
write
(
filedata
)
f
.
close
()
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
SetParametersCellProblem
(
alpha
,
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
)
# --- Run Cell-Problem
# Optional: Check Time
# t = time.time()
...
...
@@ -89,17 +120,19 @@ def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.get
else
:
# --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# print("Run computeMuGamma for Gamma = ", gamma)
with
open
(
InputFilePath
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^gamma=.*
'
,
'
gamma=
'
+
str
(
gamma
),
filedata
)
# filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
filedata
=
re
.
sub
(
'
(?m)^beta=.*
'
,
'
beta=
'
+
str
(
beta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^theta=.*
'
,
'
theta=
'
+
str
(
theta
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^mu1=.*
'
,
'
mu1=
'
+
str
(
mu1
),
filedata
)
filedata
=
re
.
sub
(
'
(?m)^rho1=.*
'
,
'
rho1=
'
+
str
(
rho1
),
filedata
)
f
=
open
(
InputFilePath
,
'
w
'
)
f
.
write
(
filedata
)
f
.
close
()
SetParametersComputeMuGamma
(
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# --- Run Cell-Problem
# Check Time
...
...
This diff is collapsed.
Click to expand it.
src/makePlot.py
+
22
−
9
View file @
b5835d1c
...
...
@@ -54,7 +54,10 @@ rho1 = 1.0
alpha
=
2.8
beta
=
2.0
theta
=
1.0
/
4.0
gamma
=
0.75
gamma
=
1.0
/
4.0
print
(
'
mu1:
'
,
mu1
)
print
(
'
rho1:
'
,
rho1
)
...
...
@@ -85,15 +88,17 @@ yName = 'angle'
# --- Define Parameter this function/quantity depends on:
# Options: mu1 ,lambda1, rho1 , alpha, beta, theta, gamma
# xName = 'theta'
xName
=
'
gamma
'
#
xName = 'gamma'
# xName = 'lambda1'
xName
=
'
alpha
'
# --- define Interval of x-values:
#
xmin = 0.0
#
xmax = 10.0
xmin
=
0.01
xmax
=
3.0
numPoints
=
3
xmin
=
0.0
xmax
=
10.0
#
xmin = 0.01
#
xmax = 3.0
numPoints
=
5
X_Values
=
np
.
linspace
(
xmin
,
xmax
,
num
=
numPoints
)
print
(
X_Values
)
...
...
@@ -111,7 +116,12 @@ make_Plot = True
if
RUN
:
for
x
in
X_Values
:
if
yName
==
'
q3
'
or
yName
==
'
mu_gamma
'
:
if
yName
==
'
q3
'
or
yName
==
'
mu_gamma
'
:
# if only q3 is needed .. compute 2D problem (much faster)
# fist replace old parameters in parset
SetParametersComputeMuGamma
(
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
)
# replace the sought after x value in the parset
with
open
(
path
+
"
/inputs/computeMuGamma.parset
"
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^
'
+
xName
+
'
=.*
'
,
xName
+
'
=
'
+
str
(
x
),
filedata
)
...
...
@@ -128,7 +138,10 @@ if RUN:
tmp
=
re
.
search
(
r
'
(?m)^mu_gamma=.*
'
,
output
).
group
()
# Not necessary for Intention of Program t output Minimizer etc.....
s
=
re
.
findall
(
r
"
[-+]?\d*\.\d+|\d+
"
,
tmp
)
Y_Values
.
append
(
float
(
s
[
0
]))
else
:
else
:
# Run full Cell-Problem...
# fist replace old parameters in parset
SetParametersCellProblem
(
alpha
,
beta
,
theta
,
gamma
,
mu1
,
rho1
,
InputFilePath
)
with
open
(
InputFilePath
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
re
.
sub
(
'
(?m)^
'
+
xName
+
'
=.*
'
,
xName
+
'
=
'
+
str
(
x
),
filedata
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment