Hi Geoff,
On 08/01/2014 01:19 AM, Geoff Wright wrote:
Hi Robert,
I'm new to sfepy and having a good experience so far. But I've been having some issues understanding the d_surface_flux function.. a couple of questions that might help:
- In the poisson_neumann example, if I add a post_process function which evaluates various surface fluxes the results are not what I would expect. Here is my post_process function:
def post_process(out, pb, state, extend=False): from sfepy.base.base import Struct
flx = pb.evaluate('d_surface_flux.2.Gamma(coef.sigma, t)',
mode='el_avg') print "Flux, entire surface:", np.sum(flx), flx.max(), flx.min()
You should use mode='el' here, see [1] (the message and below). Then the sum equals to:
aa = pb.evaluate('d_surface_flux.2.Gamma(coef.sigma, t)',
mode='eval')
print "total flux eval: ", aa
[1] https://groups.google.com/d/msg/sfepy-devel/xfzjsLSRHvM/3W8Uacy5I9QJ
snkf = pb.evaluate('d_surface_flux.2.Gamma_Left(coef.sigma, t)',
mode='eval') print "Sink flux: ", snkf
srcf = pb.evaluate('d_surface_flux.2.Gamma_Right(coef.sigma, t)',
mode='eval') print "Source flux: ", srcf
blkf = pb.evaluate('d_surface_flux.2.Gamma_N(coef.sigma, t)',
mode='eval') print "Block flux: ", blkf
return out
I would expect that "Flux, entire surface" would be approximately zero, and the sink flux and source flux should be approximately equal but opposite sign, and block flux to be zero. Since Gamma_N is supposed to have a zero neumann condition on it my understanding is that flux would only be present over Gamma_Left and Gamma_Right and that they would be equal but opposite sign. What am I missing here?
When I use the 'el' mode instead of 'el_avg', and remove the dw_surface_integrate term from the equation, I get:
Flux, entire surface: 1.23780929311e-07 0.00362888105245 -0.00337552105702 Sink flux: 0.0971430725276 Source flux: -0.0971353016007 Block flux: -7.64714595901e-06 total flux eval: 1.23780929311e-07
which is what you expected. It seems that you left the flux source term dw_surface_integrate in the equation.
- If I compute surface_flux using mode='el_avg' and then sum the results, why is that number not equal to surface_flux computed with mode='eval'? Whats the difference?
See above :) The 'el_avg' modemode divides the resulting integrated value in an element by the volume of that element, which is not what you want to do with flux - you need just an integral over each element, which is what the 'el' mode does.
r.