Magnetostrain tensor product matrix

  • horep
  • New Member
  • New Member
More
1 year 2 months ago - 1 year 2 months ago #4793 by horep
Hi,

When solving micromagnetics including elasticity, it is necessary to build a quadratic form of the kind
m1*m1 -1/3 m1*m2     m1*m3
m2*m1     m2*m2 -1/3 m2*m3 
m3*m1      m3*m2     m3*m3 -1/3

from a given magnetisation with components (m1,m2,m3). I had originally planned on building this using a GridFunction, but I am using a first order FE space, so it is inappropriate for this quadratic function when used in quadrature (building the linear system).


The documentation isn't massively clear, but I am thinking I should build it using a CoefficientFunction as follows.
Code:
Code:
fes_mag = VectorH1(mesh, order=1) mag_grid_func = GridFunction(fes_mag) give_random_magnetisation(mag_grid_func) # simply a function that fills each DoF with a random value such that the magnitude at each node is 1. m1, m2, m3 = mag_grid_func.components mymatrix = CoefficientFunction((m1*m1 - 1/3,m1*m2, m1*m3, m2*m1, m2*m2 - 1/3, m2*m3, m3*m1, m3*m2, m3*m3 - 1/3), dims=(3, 3))


If there is a better way, or built-in method for doing this I would appreciate it.

EDIT: I have attempted to upload a file of a basic code, but the add files button seems non-functional. It reports "Error Unable to get properties for the image." despite me uploading either .py and .ipynb or a .zip file containing them.
Last edit: 1 year 2 months ago by horep. Reason: formatting 4
More
1 year 2 months ago - 1 year 2 months ago #4794 by joachim
mymatrix = OuterProduct (mag_grid_func, mag_grid_func) - 1/3*Id(3)
print (mymatrix)

best, Joachim
 
Last edit: 1 year 2 months ago by joachim.
The following user(s) said Thank You: horep
Time to create page: 0.154 seconds