Forwarding to the list...
-------- Forwarded Message --------
Subject: Aw: [sfepy] Re: Store material parameters of composite
Date: Fri, 5 Jul 2019 14:53:55 +0200
From: Jochen Dreyer <J3R(a)gmx.net>
To: Robert Cimrman <cimrman3(a)ntc.zcu.cz>
Hi Robert,
Attached the minimal working example and corresponding mesh. The temperature
dependent thermal conductivity of air is used for the pores and a constant one
for the solids. The values are then used to calculate the local heat flux in
the porous structure.
Regarding your suggestions:
You were right, Omega was the whole domain and idx_pore = Po worked.
I had separate regions for Solid and Pore before but couldn't figure out how to
access their conductivity in the post_process function. Anyway, everything is
working now and I actually like it better now than with the two regions I used
before.
BTW, I wanted to post the above in the forum but didn't see how to upload files
in the mailman 3 web interface...
Thanks a lot and kind regards,
Jochen
*Gesendet:* Mittwoch, 03. Juli 2019 um 18:32 Uhr
*Von:* "Robert Cimrman" <cimrman3(a)ntc.zcu.cz>
*An:* sfepy(a)python.org
*Betreff:* [sfepy] Re: Store material parameters of composite
Dear Jochen,
On 7/3/19 11:23 AM, jd766(a)cam.ac.uk wrote:
> Dear Robert,
>
> Thanks a lot for the hint. I got it working now. The example you pointed
out did work for me in the sense that I was able to access both region
conductivities in the post_process function. However, I couldn’t get a material
function for a temperature dependent conductivity working.
If you want, send a minimal working example - we can have a look.
> But your comment regarding the coordinates outside the Pore cells pointed
me in the right direction. This is how I solved it now (I’m not a programmer
and am sure there are more elegant ways to do it):
>
> def return_indices_of_a(a, b):
> b_set = set(b)
> return [i for i, v in enumerate(a) if v in b_set]
>
> def material_func(ts, coors, problem, equations=None, mode=None, **kwargs):
> """
> Returns the thermal conductivity of the porous material.
> """
> ev = problem.evaluate
> if mode == 'qp':
> Om = problem.domain.regions['Omega'].get_cells()
> Po = problem.domain.regions['Pore'].get_cells()
> Fi = problem.domain.regions['Fill'].get_cells()
>
> T_omega = np.array(ev('ev_volume_integrate.2.Omega(T)', mode='qp',
verbose=False))
>
> val = np.zeros(T_omega.shape)
>
> idx_pore = return_indices_of_a(Om,Po)
> idx_fill = return_indices_of_a(Om,Fi)
IMO you could just use
idx_pore = np.searchsorted(Om, Po)
or, if Omega is the whole domain
idx_pore = Po
(Not tested!)
> val[idx_pore,:,0,0]= (-7.61404 + 0.14152*T_omega[idx_pore,:,0,0] -
1.09156e-4*T_omega[idx_pore,:,0,0]**2 + 4.16029e-8*T_omega[idx_pore,:,0,0]**3)/1000
> val[idx_fill,:,0,0]=1
>
> output('conductivity: min:', val.min(), 'max:', val.max())
>
> val.shape = (val.shape[0] * val.shape[1], 1, 1)
> return {'val' : val}
>
> materials = {
> 'Omega' : 'material_func',
> }
>
> Now I have a temperature dependent conductivity for the pores and can
access both, the pore and solid conductivities using:
> problem. evaluate('ev_integrate_mat.2.Omega(Omega.val, T)', mode='el_avg')
Another way would be to split the integral to two: one over 'Pore' region, and
other over 'Fill' region.
Best regards,
r.
> Thanks a lot for the help and kind regards,
> Jochen