0

I'm trying to calculate the effective conductivity of a two-phase material using the sfepy library in Python. The material consists of two phases with different conductivity values.

I have a 2D mesh representing the geometry of the material stored in a .mesh file. The mesh contains information about the boundaries and regions corresponding to each phase.

To calculate the effective conductivity, I'm solving a set of Laplace equations for the electric potential in each phase using the finite element method. The equations are formulated as follows:

For phase 1:

dw_laplace.i.P1(p1.val, sX, VX) = 0

For phase 2:

dw_laplace.i.P2(p2.val, sX, VX) = 0

Here, p1.val and p2.val represent the conductivity values of phases 1 and 2, respectively. sX and VX are the test and unknown fields for the electric potential, respectively.

I have implemented the equations using the sfepy library and defined the necessary regions, materials, fields, and boundary conditions. The code runs without any errors, and I obtain the solution for the electric potential in each phase.

However, my goal is to also calculate the gradient of the potential in each phase, as it is required for further analysis. To achieve this, I have defined a post-processing function, post_process, which calculate the gradients using the ev_grad evaluation operator and save them as output data.

Here's the code snippet for post_process function:

def post_process(out, pb, state, extend=False):
    GradientX = pb.evaluate('ev_grad.i.All(VX)', mode='qp')
    out['GradientX'] = Struct(name='output', mode='cell', data=GradientX, dofs=None)
    return out

My question is how can I save the calculated gradient of the potential as a VTK file for further analysis? I noticed that the Main function call problem.setup_output() and problem.solve() with the save_results=True argument, but I'm not sure how to access the saved results or if they include the gradients.

Any guidance or suggestions on how to save the gradients of the potential as VTK files using the sfepy library would be greatly appreciated.

I implemented the equations for calculating the effective conductivity using the sfepy library. I expected to obtain the gradients of the electric potential as output and save them as VTK files. However, I'm unsure how to access the saved results or if the gradients are included in the output.

Yasi
  • 1

0 Answers0