getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Affectation of magnets


From: Konstantinos Poulios
Subject: Re: Affectation of magnets
Date: Thu, 9 Feb 2023 17:48:56 +0100

Hi,

I assume that the union of  all magnet regions "magnet_physical_surfaces_tags" is smalller than the entire domain (i.e. region -1). Then mfm is a continuous FEM, the two versions of the code that you have provided will lead to slightly different results.

This is because when you integrate on -1 you integrate also outside the magnets, where M_data will still have some non-zero value at the border with the magnet regions. In general the codes that you have provided can be simplified a lot.

If Mx and My are some constants, you do not need to define a field for them. Something like the following lines of code should work

md.add_initialized_data("Mx", Mx*1e3)
md.add_initialized_data("My", My*1e3)
for tag in magnet_physical_surfaces_tags :
  md.add_source_term(mim,'[Mx,My].B(Test_u)',tag)

if you want to add the term only once, you need to merge all regions:

all_magnets_RG = 999
for tag in magnet_physical_surfaces_tags :
   m.region_merge(all_magnets_RG, tag)
...
md.add_initialized_data("Mx", Mx*1e3)
md.add_initialized_data("My", My*1e3)
md.add_source_term(mim,'[Mx,My].B(Test_u)', all_magnets_RG)

Both codes should give equivalent results with your "Case 1" code. I hope this helps.

BR
Kostas


On Thu, Feb 9, 2023 at 11:57 AM lahoussaine BOURRICHE <lahoussaine.bourriche@gmail.com> wrote:
Hi,

I have a question about source term affectation.
I want to solve a magnetostatic problem with a lot of magnets. I tried two ways of affecting the source term of the magnets.
given a list of physical surfaces tags of the magnets, i tried these two option

Case 1 : Affectation per solid

     for tag in magnet_physical_surfaces_tags :
               M_data_x=np.zeros((1,mfm.nb_basic_dof()))
               M_data_y=np.zeros((1,mfm.nb_basic_dof()))
               vect=mfm.basic_dof_on_region(tag)
               for j in range(len(vect)):
                       M_data_x[0, vect[j]]=Mx*1e3
                       M_data_y[0, vect[j]]=My*1e3

               md.add_initialized_fem_data('aimant_x'+str(tag), mfm, M_data_x)    
               md.add_initialized_fem_data('aimant_y' +str(tag)  , mfm, M_data_y)
               md.add_source_term(mim,'[aimant_x' +str(tag)  +',aimant_y' +str(tag)  +'].B(Test_u)',tag)

Case 2 : One Affectation for all the problem (to optimize computation time)

       M_data_x=np.zeros((1,mfm.nb_basic_dof()))
       M_data_y=np.zeros((1,mfm.nb_basic_dof()))
       for tag in magnet_physical_surfaces_tags :
               vect=mfm.basic_dof_on_region(tzg)
               for j in range(len(vect)):
                       M_data_x[0, vect[j]]=Mx*1e3
                       M_data_y[0, vect[j]]=My*1e3

       md.add_initialized_fem_data('aimant_x', mfm, M_data_x)    
       md.add_initialized_fem_data('aimant_y', mfm, M_data_y)
       md.add_source_term(mim,'[aimant_x'+',aimant_y'+'].B(Test_u)',-1)

When I compare the results of both simulations I can't find the exact same result. I would like some help to understand why there is an error between both methods and if there is something I do wrong.

Thank you in advance,

I hope my mail was clear.

Best regards,

LB


np  = numpy
md  = model
mfm = meshFem

reply via email to

[Prev in Thread] Current Thread [Next in Thread]