Accessing all the E-field Components in Flexible Material Plugin Framework

joaonizerjoaonizer Member Posts: 3

Hello,

I'm developing my own material model using the LorentzExample Flexible Material Plugin Framework as the base code. I need to calculate the magnitude of the electric field when updating each component of the electric field. In short, I need to store the previous values of Ex Ey and Ez to calculate |E| inside each calculate() call.

I tried declaring Exx, Eyy and Ezz as variables similar to what we do for when storing model parameter. I initialize them as zero inside the initialize function and then update their values inside the calculate() function based on the axis value. Currently I'm implementing the calculate() function for updating each one of the components as:

float ExamplePlugin::calculate(int axis, float U, float V, float E, float* storage)
{
if (axis == 0) { 
Exx = E;
}
if (axis==1){
Eyy = E;
}
if (axis==2){
Ezz = E;
}
float E_mag = sqrt(Exx*Exx + Eyy*Eyy + Ezz*Ezz); // I need this magnitude

// ... Code for Calculating Pnp1
storage[2] = Exx;
storage[3] = Eyy;
storage[4] = Ezz;
storage[5] = E_mag;
return (V - Pnp1) / U;
}

float ExamplePlugin::calculateEx(float U, float V, float Ex, float* storage)
{
	return calculate(0, U, V, Ex, storage);
}

How can I use Ex, Ey, Ez from the previous time step to calculate the previous magnitude of the electric field and use this magnitude inside every calculate() call?

The imaterialplugin.h file gives me the scope of each calculateEx(), calculateEy() and calculateEz(), by only parsing individual components of the electric field.

  float calculateEx( float U, float V, float Ex, float* storage);
  float calculateEy( float U, float V, float Ey, float* storage);
  float calculateEz( float U, float V, float Ez, float* storage);


The only problem is that I'm not able to store the correct components. The Ey component I store in the Ey_storage field is correct (dashed red), but the Ey component I store in the Ex_storage (solid green) and Ez_storage (solid magenta) do not match, it seems to be picking some other value.


Any help on how to implement that?


Thanks in advance!

Comments

  • chris_kopetskichris_kopetski Posts: 59Ansys Employee

    As mentioned at the top of the Flexible Material Plugin Framework page, we don't really provide support for this feature. I realize that's unfortunate, but developing plugin materials can be very complicated and is beyond the scope of what we offer for technical support. Most often, this feature is used by our own development team to test new features before they are added to the main solver engine.

    To briefly answer your question... I believe the updates for Ex, Ey, Ez are handled separately, and one field component does not have access to the other components. One way to understand this limitation is to recognize that each field component is calculated at a different point in space. Simply calculating |E|^2 by summing each field component isn't really correct since the components are not at the same spatial location.

  • trobertstroberts Posts: 60Ansys Employee
    edited April 26

    To add to this Ex, Ey and Ez are solved on the Yee cell as shown. Typically one writes the update equations in such a way each axis can be handled separately, as the E fields are updated in the order of Ex, Ey and then Ez . To couple them one needs to very carefully group the components.

    I would imagine that you are not using storage fields from the correct Yee cell in your updates. For this to work you will need to ensure that the mesh covers the structure, so that all the field components are solved within the material. A necessary requirement for this is that you have the same number of field components for Ex, Ey, and Ez. Then you will need to have longer storage arrays to keep track of all the field components in the structure. Allocate these arrays on your first pass through the Ex update.


    float TwoLevelArbitraryOrientation::calculateEx( float U, float V, float Ex, float* storage )
    {
      //keep track of current index, and identify first time through the loop
      if(!firstStorageEx) {
        firstStorageEx = storage;
      } else if(firstStorageEx == storage) {
        indX = 0;
        firstIterationComplete = true;
      }
       
      //add elements to shared storage arrays on the first pass
      if(!firstIterationComplete) {
        Eyn.push_back(0.f);
        Ezn.push_back(0.f);
        Pnp1.push_back(0.f);
      }
    
      //UPDATE
    ...
    


  • joaonizerjoaonizer Posts: 6Member

    Thanks for your reply! It was really helpful.

Sign In or Register to comment.