Giter Site home page Giter Site logo

femagtools's Introduction

Introduction to Femagtools

logo

Build status

Femagtools is an Open-Source Python-API for FEMAG offering following features:

  • run Femag with a FSL script file anywhere: locally (single and multi-core), remote (ZMQ), HT Condor, Cloud (Amazon AWS, Google Cloud), Docker
  • read I7/ISA7, NC, BCH/BATCH, PLT, ERG files
  • read and write MCV files (magnetizing curves)
  • create a variety of plots
  • create FSL files from model and calculation templates and/or user specific FSL
  • create FSL files from DXF
  • create and analyze symmetrical windings
  • sizing and parameter identification
  • calculate machine characteristics by using analytic machine models
  • execute parameter studies and multi-objective optimization

The package can be used with Python 3.x on Linux, MacOS or Windows and is hosted on github: https://github.com/SEMAFORInformatik/femagtools/` where also many examples can be found in the examples directory. Contributions and feedback to this project are highly welcome.

The installation can be done in the usual ways with pip:

pip install femagtools[all]

([all] pulls in all optional dependencies.

For details see the documentation http://docs.semafor.ch/femagtools

Modules and Scripts

The package provides following modules:

  • mcv, tks, jhb, losscoeffs: handling magnetizing curves and iron losses
  • erg, bch: read ERG, BCH/BATCH files created by FEMAG
  • model, fsl: create machine and calculation models
  • femag: manage the FEMAG calculation
  • airgap: read airgap induction file created by a previous calculation
  • machine: analytical machine models
  • windings: create and analyze windings
  • grid: running parameter variations
  • opt: running multi objective optimizations
  • plot: creating a variety of plots
  • dxfsl: create FSL from DXF
  • isa7, nc: read ISA7/I7, NC (NetCDF) files
  • windings: create and analyze windings
  • forcedens: read PLT files
  • amazon, google, condor, multiproc: engines for the calculation in Cloud and HTCondor environments or locally using multiple cores

The following modules can be executed as script:

  • bch: print content in json format if invoked with a BCH/BATCH file as argument
  • bchxml: produces an XML file when invoked with a BCH/BATCH file as argument
  • plot: produces a graphical report of a BCH/BATCH file
  • airgap: prints the base harmonic amplitude of the radial component of the airgap induction when invoked with the file name of an airgap induction file
  • mcv: print content in json format if invoked with a MC/MCV file as argument
  • dxfsl/conv: show geometry or create fsl from dxf

Usage

For many applications it is sufficient to import femagtools:

import femagtools

The version can be checked with:

femagtools.__version__
'1.0.nn'

femagtools's People

Contributors

bhzunami avatar dapu avatar gamsler avatar niklaswitzel avatar ronaldtanner avatar sasrigais avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

femagtools's Issues

install error

While installing femagtools an error raised:

File "<string>", line 20, in <module> File "d:\users\tbbaunma\appdata\local\temp\pip-afksl_-build\setup.py", line 14, in <module> with open(path.join(here, 'README.rst'), encoding='utf-8') as f: TypeError: 'encoding' is an invalid keyword argument for this function

Tested on windows (python 2.7.10) and debian (python 2.7.3) with pip.

set cu_losses parameter in model only

CU-Losses-1 and -2 overwite model attributes when running a simulation:
``
m.cufilfact = ${model.get('cufilfact', 0.45)}
m.culength = 100*${model.get('culength', 1.4)}
m.cuconduct = ${model.get('cuconduct', 56e6)}
m.numlayers = ${model.get('num_layers', 1)}
m.conheight = ${model.get('conheight', 0.0)}
m.contemp = ${model.get('wind_temp',20.0)}
m.emodul = ${model.get('emodul', 210e9)}
m.poison = ${model.get('poisson', 0.3)}
m.dampfact = ${model.get('dampfact', 0.0)}
m.thcond = ${model.get('thcond', 30.)}
m.thcap = ${model.get('thcap', 480.0)}
m.slot_indul = ${model.get('slot_indul',0.0)*1e3}
m.dia_wire = ${model.get('dia_wire',0.0)}
m.num_wire = ${model.get('num_wire',0.0)}
''

bchreader: felosses properties StatorStJo and StatStZa read incorrectly

Part of BCH File:
image

Data in bch.losses[-1]['fft']:
{{{
'staza': [],
'stajo': [[1, 833.0, 0.0, 152.523], [3, 2500.0, 0.0, 48.1], [5, 4167.0, 0.0, 5.126],
[1, 833.0, 0.0, 84.205], [3, 2500.0, 0.0, 107.965], [5, 4167.0, 0.0, 63.212], [7, 5833.0, 0.0, 32.101], [9, 7500.0, 0.0, 0.013]]
}}}

Read values from logfile 'FEMAG-FSL.log'

Read a value from logfile with a given regex/pattern

read_from_log(pattern):
    result=[]
    pat=re.compile(pattern)
    with open(os.path.join(self.workdir, 'FEMAG-FSL.log')) as f:
        for line in f:
            m = pat.search(line)
            if m:
                result.append(float(line.split(':')[-1].split()[0]) )
    return result

Order-numbers > 1000 break bch.Reader.read()

FEMAG does not save order-numbers > 1000 in the BCH-File (Fe-Hysteresis- and Eddy current Losses for example). This produces nan values during parsing. Finally casting the order to int in mehtod __read_hysteresis_eddy_current_losses() will throw an cannot convert float NaN to integer Error
I think, that's not directly a femagtools issue or should be handeld by femagtools. It should be fixed in FEMAG instead, by allowing order numbers > 1000.

handle new MCV types

Valid Types with Femag Rev 2323:
C M_TYPE() : Type der Kurve: -1 AC, 1 Softiron, 2 PM (m_curves() = 1)
C 3 S-Iron-alfa 4 PM-Brem (m_curves() > 1)
C 5 PM-B(H,alfa) (m_curves(
) > 1)
C 6 Softiron Punching (m_curves() > 1)
C 7 Softiron Tension (m_curves(
) > 1)
C 8 Softiron Temperatur (m_curves(*) > 1)
C

FSL arguments in run command

The command run(filename, options) in femag.py should have one more parameter to add options for the FSL file.

Femag.run(filename, options=['-b'], fsl_args=[])

The fsl_args should be a list of strings.

KeyError: impfml.mako

Testfall:

  1. Windows-Umgebung mit femag environemnt
  2. Testfälle in femagtools\examples funktioniert
  3. Testfall in femagtools\examples\model-creation\statorRotor3-imp-fml.py liefert folgende Meldung:
    100

MultiprocEngine: PermissionError: [Errno 13] Permission denied

stacktrace:

Traceback (most recent call last):
File "parvar.py", line 135, in
results = parvar(parvardef, machine, operatingConditions, engine)
File "/home/tar/projects/femagtools/femagtools/grid.py", line 159, in call
status = engine.join()
File "/home/tar/projects/femagtools/femagtools/multiproc.py", line 85, in join
results.append(task.get())
File "/usr/lib64/python3.4/multiprocessing/pool.py", line 599, in get
2016-11-05 13:54:41,017 FEMAG /home/tar/parvar/5: femag.fsl
raise self._value
PermissionError: [Errno 13] Permission denied

Consider magnet material in parameter-variation properly

The Grid class does not consider the magnet properties passed by the magnets parameter during initialisation.

The calls to builder.create_model in Grid.setup_model and Grid.__call__ need self.femag.magnets as second parameter to fix that issue. If that second parameter is missing, builder.create_magnet, wich is called by builder.create_model, will use the default values m.remanenc = 1.2 and m.relperm = 1.05

121 f.write('\n'.join(builder.create_model(model, self.femag.magnets) +

247 builder.create_model(model, self.femag.magnets) +

BCH/BATCH plots

to easily create plots from BCH/BATCH files such as cogging, PM/Rel sim, Ld-Lq, Psid-Psiq-Ident.

Load existing model files

Example
`
machine = dict(name="PM 270 L8")
workdir = os.path.join(
os.path.expanduser('~'), 'femag')
femag = femagtools.Femag(workdir)

operatingConditions = dict(
angl_i_up=-38.7,
calculationMode="pm_sym_fast",
wind_temp=60.0,
magn_temp=60.0,
current=108.0,
speed=52.5)

r = femag(machine,
operatingConditions)
`

add plots after run_model

Following plots should be createable on demand (See script.profemag.ch:)

  • Field Lines
  • Color gradation: Babs, Bx, By, Br, Bt, Habs, Hx, Hy, Hr, Ht, relperm, rem, Wm, Bdev, Mrdev, Vpot, demoag, pmfelosd

either with automatic or explicit scaling.

Examples:

  • plots=['field_lines', 'Babs']
  • plots=[('field_lines', 10) , ('Babs', 0, 2.0)]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.