nemocrys / pyelmer

A python interface to Elmer.
GNU General Public License v3.0
53 stars 15 forks source link

H-B curve in material definitions. #12

Closed mjfwest closed 1 year ago

mjfwest commented 1 year ago

I'm trying to work out how one should define a nonlinear BH curve for a MagnetoDynamics2D simulation. I think the SIF file I should end up with should look like:

Material 2
 Name = "Iron"
 Electric Conductivity = 0
! keyword is H-B curve, but values are in B-H format
 H-B Curve = Variable coupled iter
 Real Monotone Cubic
 Include BH
 End
End 

I've tried as yml file

m230-35:
  #Density: 7900.0  # 20°C
  Electric Conductivity: 1.37e+6  # 20°C
  #Emissivity: 0.111  # 200°C
  #Heat Capacity:  470.0 # 20°C
  #Heat Conductivity: 15.0 # 20°C
  #Relative Permeability: 1
  #Relative Permittivity: 1
  H-B Curve : 
    Variable: "dummy" 
    Cubic: 'Monotone'
    include: 'HB' 

which results in:

! m230-35
Material 4
  Electric Conductivity = 1370000.0
  H-B Curve = {'Variable': 'dummy', 'Cubic': 'Monotone', 'include': 'HB'}
End
arvedes commented 1 year ago

In python, the yaml-file is a dictionary. By using the syntax

m230-35:
 Electric Conductivity: 1.37e+6  # 20°C
 H-B Curve :
  Variable: "dummy" 
  Cubic: 'Monotone'
  include: 'HB' 

with the colons in the definition of the H-B Curve you created a second dictionary inside the on with the material data - which is dumped as a string into the sif-file by pyelmer. Therefore you get

H-B Curve = {'Variable': 'dummy', 'Cubic': 'Monotone', 'include': 'HB'}

which is the second dictionary.

To get the desired output you need a string instead of a dictionary. As Elmer doesn't allow for the text to be in the same line, you need to use a multiline yaml-string. I'd suggest to use the pipe '|' symbol:

m230-35:
  Electric Conductivity: 1.37e+6  # 20°C
  H-B Curve: |
   Variable "dummy" 
   Cubic 'Monotone'
   include 'HB' 

You could add some additional spaces in front of "Cubic 'Monotone'" and "include 'HB'" to get a nice-looking sif-file.