In [1]:
import femagtools.mcv
In [2]:
mcvreader = femagtools.mcv.Reader()
mcvreader.readMcv('M270-35A.MC')
In [3]:
mcvreader.get_results()
Out[3]:
Display the B(H) curve in a linear plot:
In [4]:
import matplotlib.pyplot as plt
plt.plot(mcvreader['curve'][0]['hi'], mcvreader['curve'][0]['bi'])
plt.grid()
plt.show()
or with the plot module:
In [5]:
import femagtools.plot
femagtools.plot.mcv_hbj(mcvreader, log=True)
plt.show()
Display the relative permeability:
In [6]:
femagtools.plot.mcv_muer(mcvreader)
plt.show()
A new BH curve can be created from a dict:
In [7]:
mcvData = dict(curve=[ dict(
bi=[0.0, 0.09, 0.179, 0.267, 0.358,
0.45, 0.543, 0.6334, 0.727,
0.819, 0.9142, 1.0142, 1.102,
1.196, 1.314, 1.3845, 1.433,
1.576, 1.677, 1.745, 1.787,
1.81, 1.825, 1.836],
hi=[0.0, 22.16, 31.07, 37.25, 43.174,
49.54, 56.96, 66.11, 78.291,
95, 120.64, 164.6, 259.36,
565.86, 1650.26, 3631.12, 5000, 10000,
15000, 20000, 25000, 30000, 35000, 40000]
)],
ctype=femagtools.mcv.MAGCRV,
name='m270-35a',
desc=u"Demo Steel",
ch=0.0,
cw_freq=2.0,
cw=1.68)
The MCV dict must contain a list of curves. If the material is soft iron this list has exactly one dict with the 2 lists of bi and hi.
In [8]:
femagtools.plot.mcv_hbj(mcvData, log=False)
plt.show()
In [9]:
mcv = femagtools.mcv.MagnetizingCurve(mcvData)
mcv.writefile('m270-35a')
Out[9]:
In [10]:
mcvreader.readMcv('m270-35a.MCV')
In [11]:
mcvreader['curve'][0]['bi']
Out[11]:
Magnetic curve dicts can also be created from TKS files:
In [12]:
import femagtools.tks
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
tks = femagtools.tks.read('TKS-M400-65A.txt')
femagtools.plot.mcv_hbj(tks, log=False)
plt.show()
If the TKS file includes losses they are fitted with the Jordan approximation:
In [13]:
ch = tks['ch']
alpha = tks['ch_freq']
cw = tks['cw']
beta = tks['cw_freq']
gamma = tks['b_coeff']
femagtools.plot.felosses(tks['losses'], (ch, alpha, cw, beta, gamma), log=False)
plt.show()
In [14]:
magnets = [dict(name='MX-333', remanenc=1.2, relperm=1.05)]
In cases where this not applicabble a magnetizing curve can be referenced:
In [15]:
magnets=[dict(name='BH53M', mcvkey='BH53M',
orient='mcartiso', rlen=1.0)]
The mcvkey can either reference a file or an entry in the magnetizing curve dict.