
Hi,
I am attempting to solve heat diffusion in a spin valve. I have created a 3D mesh of part of the valve which has a hotspot on the wire and i want to see the heat diffusion into the substrate below. The wire is treated as being insulated with the surroundings and the only heat flow is into the substrate. I have found out that the mesh needs to be separate volumes for the wire and substrate or I get a linesearch failed message. I have an image of the spin valve and what the temperature distribution is like in real life and i am trying to recreate it. I can get the problem to work with 2 boundary conditions: the hotspot at 25C and bottom of substrate at 21C. Is there a way to set one ebcs and initial and see how the heat diffuses into the substrate that way? Also there appears to be some strange overlap effects between the wire and subs as my regions overlap at z=0 if there a way to stop this given there is also an interface conductance I need to factor in at z =0?
My code:
from __future__ import absolute_import from sfepy import data_dir import numpy as nm filename_mesh = data_dir + '/3_vol.mesh'
materials = { 'coef4' : ({'val' : 1.2},), 'coef5' : ({'val' : 240},), 'coef6' : ({'val' : -2.5},), 'Ag' : ({'K' : 240 * nm.eye(3)},), 'Cu' : ({'K' : 240 * nm.eye(3)},), 'S' : ({'K' : 1.2 * nm.eye(3)},), }
regions = { 'Omega' : 'all', 'subs' : ('cells of group 1', 'cell'), 'Ag_wire' : ('cells of group 2 ', 'cell'), 'Cu_wire' : ('cells of group 3 ', 'cell'), 'Gamma_Left' : ('vertices in (x == 7.8) & ( z > 0)', 'facet'), 'Gamma_Right' : ('vertices in (x == 27.8) & ( z > 0)', 'facet'), 'Gamma_Bottom' : ('vertices in (x > 7.8) & (x < 27.8) & ( y < 3) & ( y > 2) & ( z == 0) ', 'facet'), 'Sub_Bottom' : ('vertices in ( z == -2) ', 'facet'), 'Wire_top' : ('vertices in ( z == 1) ', 'facet'), }
fields = { 'temperature' : ('real', 1, 'Omega', 1), }
variables = { 't' : ('unknown field', 'temperature', 0), 's' : ('test field', 'temperature', 't'), }
ebcs = { 't1' : ('Gamma_Left', {'t.0' : 25}), 't2' : ('Sub_Bottom', {'t.0' : 21}), }
integrals = { 'i' : 2, } equations = { 'temperature' : """ dw_diffusion.i.Ag_wire(Ag.K, s,t) dw_diffusion.i.Cu_wire(Cu.K, s,t) dw_diffusion.i.subs(S.K, s,t) = 0 """ } solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0,
}),
} options = { 'nls' : 'newton', 'ls' : 'ls', }

Hi py17js,
can you send also the mesh file (small/coarse version, if possible, or provide a link) so that we are able to run the code?
The problem is linear, so there should be no linesearch message, provided the solver tolerances are not too low.
r.
On 04. 02. 21 18:58, py17js@leeds.ac.uk wrote:
Hi,
I am attempting to solve heat diffusion in a spin valve. I have created a 3D mesh of part of the valve which has a hotspot on the wire and i want to see the heat diffusion into the substrate below. The wire is treated as being insulated with the surroundings and the only heat flow is into the substrate. I have found out that the mesh needs to be separate volumes for the wire and substrate or I get a linesearch failed message. I have an image of the spin valve and what the temperature distribution is like in real life and i am trying to recreate it. I can get the problem to work with 2 boundary conditions: the hotspot at 25C and bottom of substrate at 21C. Is there a way to set one ebcs and initial and see how the heat diffuses into the substrate that way? Also there appears to be some strange overlap effects between the wire and subs as my regions overlap at z=0 if there a way to stop this given there is also an interface conductance I need to factor in at z =0?
My code:
from __future__ import absolute_import from sfepy import data_dir import numpy as nm filename_mesh = data_dir + '/3_vol.mesh'
materials = { 'coef4' : ({'val' : 1.2},), 'coef5' : ({'val' : 240},), 'coef6' : ({'val' : -2.5},), 'Ag' : ({'K' : 240 * nm.eye(3)},), 'Cu' : ({'K' : 240 * nm.eye(3)},), 'S' : ({'K' : 1.2 * nm.eye(3)},), }
regions = { 'Omega' : 'all', 'subs' : ('cells of group 1', 'cell'), 'Ag_wire' : ('cells of group 2 ', 'cell'), 'Cu_wire' : ('cells of group 3 ', 'cell'), 'Gamma_Left' : ('vertices in (x == 7.8) & ( z > 0)', 'facet'), 'Gamma_Right' : ('vertices in (x == 27.8) & ( z > 0)', 'facet'), 'Gamma_Bottom' : ('vertices in (x > 7.8) & (x < 27.8) & ( y < 3) & ( y > 2) & ( z == 0) ', 'facet'), 'Sub_Bottom' : ('vertices in ( z == -2) ', 'facet'), 'Wire_top' : ('vertices in ( z == 1) ', 'facet'), }
fields = { 'temperature' : ('real', 1, 'Omega', 1), }
variables = { 't' : ('unknown field', 'temperature', 0), 's' : ('test field', 'temperature', 't'), }
ebcs = { 't1' : ('Gamma_Left', {'t.0' : 25}), 't2' : ('Sub_Bottom', {'t.0' : 21}), }
integrals = { 'i' : 2, } equations = { 'temperature' : """ dw_diffusion.i.Ag_wire(Ag.K, s,t) dw_diffusion.i.Cu_wire(Cu.K, s,t) dw_diffusion.i.subs(S.K, s,t) = 0 """ } solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0, }), } options = { 'nls' : 'newton', 'ls' : 'ls', }
SfePy mailing list -- sfepy@python.org To unsubscribe send an email to sfepy-leave@python.org https://mail.python.org/mailman3/lists/sfepy.python.org/ Member address: cimrman3@ntc.zcu.cz

Thanks for the reply robert.
I have now read up about interface conductances and realised that I should need a gap between the wire and substrate to correctly implement this as the overlapping boundaries for the wire and subs yielding the wrong flux. I have manged to get my latest code to run and simulate the heat flow out of the wire and into the substrate. I am still unsure as to how I correct input there thermal conductivities and interface conductance if the conductivities are in W/mK and interface conductance is W/m^2K.
Link to mesh: https://www.mediafire.com/file/k6211q4oq60xa8a/2_vol_raised.mesh/file
Problem file:
from __future__ import absolute_import from sfepy import data_dir import numpy as nm
filename_mesh = data_dir + '/2_vol_raised.mesh'
materials = { 'coef4' : ({'val' : 0.83333},), 'coef5' : ({'val' : 240},), 'coef6' : ({'val' : -0.4},), 'Ag' : ({'K' : 240 * nm.eye(3)},), 'Cu' : ({'K' : 240 * nm.eye(3)},), 'S' : ({'K' : 1.2 * nm.eye(3)},), }
regions = { 'Omega' : 'all', 'subs' : ('cells of group 2', 'cell'), 'subs1' : ('vertices in ( z <= 0)', 'cell'), 'Ag_wire' : ('cells of group 1 ', 'cell'), 'Ag_wire1' : ('vertices in ( z >= 1E-5)', 'cell'), 'Gamma_Left' : ('vertices in (x == 7.8) & ( z >= 1E-5)', 'facet'), 'Gamma_Right' : ('vertices in (x == 27.8) & ( z > 0)', 'facet'), 'Gamma_Bottom' : ('vertices in (x > 7.8) & (x < 27.8) & ( y < 3) & ( y > 2) & ( z == 1E-5)', 'facet'), 'Sub_Bottom' : ('vertices in ( z == -1) ', 'facet'), 'Sub_Top' : ('vertices in (x > 7.8) & (x < 27.8) & ( y < 3) & ( y > 2) & ( z == 0) ', 'facet'), 'Wire_top' : ('vertices in ( z == 1) ', 'facet'), }
fields = { 'temperature' : ('real', 1, 'Omega', 1), }
variables = { 't' : ('unknown field', 'temperature', 0), 's' : ('test field', 'temperature', 't'), }
ebcs = { 't1' : ('Gamma_Left', {'t.0' : 25}), 't2' : ('Sub_Bottom', {'t.0' : 10}), }
ics = { 'ic' : ('Omega', {'t.0' : 10.0}), }
integrals = { 'i' : 2, } equations = { 'temperature' : """ dw_laplace.i.Ag_wire(coef5.val,s,t) -dw_surface_integrate.i.Gamma_Bottom(coef6.val,s) = dw_laplace.i.subs(coef4.val,s,t) dw_surface_integrate.i.Sub_Top(coef6.val,s) """ } solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', {'i_max' : 1, 'eps_a' : 1e-10, 'eps_r' : 1.0,
}),
} options = { 'nls' : 'newton', 'ls' : 'ls', }

On 06. 02. 21 16:42, py17js@leeds.ac.uk wrote:
Thanks for the reply robert.
I have now read up about interface conductances and realised that I should need a gap between the wire and substrate to correctly implement this as the overlapping boundaries for the wire and subs yielding the wrong flux. I have manged to get my latest code to run and simulate the heat flow out of the wire and into the substrate. I am still unsure as to how I correct input there thermal conductivities and interface conductance if the conductivities are in W/mK and interface conductance is W/m^2K.
Now the mesh is split into two disjoint parts that do not communicate - how do you want to connect the parts - do you have an equation on the interface? It is related to the units - those depend on whether they relate to a volume or surface (= the domains of the weak form integrals).
BTW. in order to obtain temperature evolution in time, have a look at [1], for example.
r.
[1] http://sfepy.org/doc/examples/diffusion-time_advection_diffusion.html

After reading some more literature it turns out that the interface conductance should be sorted out by the simulation by just including the two conductivities and allowing the heat flow between them. However, I am getting a lineseach failure again. When I use a smaller file size mesh my code works however when a larger mesh is used i get the linesearch failure.
The code which works is the single_vol. The redefined_vol file is exactly the same but with the mesh filename changed.
http://www.mediafire.com/file/9suv03rt4odr870/single_vol.mesh/file http://www.mediafire.com/file/bkmi2hw4uugqeoa/single_vol.py/file http://www.mediafire.com/file/3n1tna5nn1n6gre/redefined_vol.py/file http://www.mediafire.com/file/jmdu6j6jwek0had/redefined_vol.mesh/file

Hi,
the cause of the failure lies in the region definitions. While the mesh entity selection statements are correct in the exact arithmetic, in practice floating point values should not be compared using the '==' operator.
The failure disappears with:
'subs1' : ('vertices in ( z <= 0)', 'cell'),
#'Ag_wire1' : ('vertices in ( z >= 0)', 'cell'),
'Ag_wire1' : ('r.Omega -c r.subs1', 'cell'),
I suspect the original (commented out) definition misses some element(s) which causes the resulting matrix to be singular.
Also replace, to be on the safe side, definitions like
'Gamma_Left' : ('vertices in (x == 7.8) & ( z > 0)', 'facet'),
with something like
'Gamma_Left' : ('vertices in (x < 7.80000001) & ( z > 0)', 'facet'),
etc. Try running
python3 simple.py redefined_vol.py --save-regions-as-groups
or better
python3 simple.py redefined_vol.py --save-regions
to verify the regions are correctly defined.
r.
On 12. 02. 21 14:02, py17js@leeds.ac.uk wrote:
After reading some more literature it turns out that the interface conductance should be sorted out by the simulation by just including the two conductivities and allowing the heat flow between them. However, I am getting a lineseach failure again. When I use a smaller file size mesh my code works however when a larger mesh is used i get the linesearch failure.
The code which works is the single_vol. The redefined_vol file is exactly the same but with the mesh filename changed.
http://www.mediafire.com/file/9suv03rt4odr870/single_vol.mesh/file http://www.mediafire.com/file/bkmi2hw4uugqeoa/single_vol.py/file http://www.mediafire.com/file/3n1tna5nn1n6gre/redefined_vol.py/file http://www.mediafire.com/file/jmdu6j6jwek0had/redefined_vol.mesh/file
SfePy mailing list -- sfepy@python.org To unsubscribe send an email to sfepy-leave@python.org https://mail.python.org/mailman3/lists/sfepy.python.org/ Member address: cimrman3@ntc.zcu.cz
participants (2)
-
py17js@leeds.ac.uk
-
Robert Cimrman