Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Magnetostrain tensor product matrix

  • horep
  • New Member
  • New Member
More
11 months 4 weeks ago - 11 months 4 weeks 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: 11 months 4 weeks ago by horep. Reason: formatting 4
More
11 months 4 weeks ago - 11 months 4 weeks ago #4794 by joachim
mymatrix = OuterProduct (mag_grid_func, mag_grid_func) - 1/3*Id(3)
print (mymatrix)

best, Joachim
 
Last edit: 11 months 4 weeks ago by joachim.
The following user(s) said Thank You: horep
Time to create page: 0.139 seconds