-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixed_potential.py
111 lines (98 loc) · 2.72 KB
/
fixed_potential.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright (C) 2023 Davide Riccobelli
#
# This file is part of dielectric_elastomer_baloon library for FEniCS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from spherical_de import ElectroactiveSphere
from bifenics import ArclengthContinuation, ParameterContinuation
from dolfin import Function, project, parameters, Constant
parameters["allow_extrapolation"] = False
XDMF_options = {
"flush_output": True,
"functions_share_mesh": True,
"rewrite_function_mesh": False,
}
td = 0.9
te = 0.9
Rm = te
Ri = Rm * td
t1 = 1 - Rm
t2 = Rm - Ri
H = t1 + t2
dh = 1e-5
K = 1000
sphere = ElectroactiveSphere(
thickness_in=t2,
thickness_out=t1,
mui=1,
muo=10,
eps_out=1,
dh=dh,
m=4,
K=K,
Jm=97.2,
dielectric_out=False,
)
analysis = ParameterContinuation(
sphere,
"deltaphi",
start=0,
end=0.3 * t2,
dt=0.25,
saving_file_parameters=XDMF_options,
save_output=False,
)
actual_state = analysis.run()
class ElectroactiveSphereRestart(ElectroactiveSphere):
def mesh(self):
self.my_mesh = sphere.my_mesh
self.boundaries = sphere.boundaries
self.no_diel_layer_dof = sphere.no_diel_layer_dof
self.domains = sphere.domains
return self.my_mesh
def initial_guess(self, V):
initial_guess = Function(V)
projected_actual_state = project(actual_state[0], V)
initial_guess.assign(projected_actual_state)
return initial_guess
def parameters(self):
deltaphi = actual_state[1]["deltaphi"]
p0 = actual_state[1]["p0"]
return {"deltaphi": Constant(float(deltaphi)), "p0": Constant(float(p0))}
restartsphere = ElectroactiveSphereRestart(
thickness_in=t2,
thickness_out=t1,
mui=1,
muo=10,
dh=dh,
m=4,
K=K,
Jm=97.2,
dielectric_out=False,
)
analysis = ArclengthContinuation(
restartsphere,
"p0",
start=0,
end=-1,
ds=0.01,
initial_direction=-1,
saving_file_parameters=XDMF_options,
save_output=False,
first_step_with_parameter_continuation=False,
max_steps=1000,
predictor_type="secant",
n_step_for_doubling=2,
)
analysis.run()