Hi,
I am trying to simulate an electrostatic problem with the boundary condition (electric potential) not fixed but dependent on local charge density. I am very new to SfePy and after learning from the online examples, I was able to set up the simulation with a fixed boundary condition, which works well.
Next I tried to set up a function for the field-dependent boundary condition as the following. Example function taken from poisson_field_dependent_material example http://sfepy.org/doc-devel/examples/diffusion/poisson_field_dependent_materi...
def set_potential(ts, coors, problem, equations=None, mode=None, **kwargs):
# this function updates the potential at region: Electrode
if mode=='qp':
E_values = problem.evaluate('ev_grad.i.Electrode(v)', mode='qp', verbose=False) # calculating the electric field (potential gradient) at the electrode (a short straight line)
return UpdatedPotential(E_values) # the potential on this electrode depends on the local charge density (which is proportional to the local electric field calculated above)
else:
return np.zeros(len(coors)) # for the initial step
ebcs = {
'v1' : ('Boundary', {'v.all' : 1}), # this is one edge of the square box
'v2' : ('Electrode', {'v.all' : 'set_potential'}), # this is one short straight line inside the square. In the fixed ebcs case, it is set to 0
}
functions = {
'set_potential' : (set_potential,),
}
However, it looks like it doesn't really update the boundary condition during runtime. The set_potential function is only called once at the beginning. Any ideas what is wrong here? Thanks a lot.
YT