-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
71 lines (46 loc) · 1.43 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import numpy as np
import pathlib as pl
import femm as fe
import motor
import materials as mat
class MotorSimulation():
def __init__(self, fname = None, overwrite = False):
if fname is not None:
p = pl.Path(fname)
if p.exists() and (not overwrite):
self.open_previous(str(p))
else:
self.new(str(p))
def open_previous(self, fname):
fe.openfemm()
fe.opendocument(fname)
self.fname = fname
def new(self, fname):
fe.openfemm()
fe.newdocument(0)
fe.mi_saveas(fname)
self.fname = fname
#add air to problem by default
air = mat.Material('Air')
air.add()
@staticmethod
def zoom(method = 'natural'):
if method.lower() == 'natural':
fe.mi_zoomnatural()
def save(self):
fe.mi_saveas(self.fname)
def saveas(self, fname):
fe.mi_saveas(fname)
self.fname = fname
#%% Create Simulation
sim = MotorSimulation('test.fem', overwrite = True)
#%% MATERIALS
R35e = mat.Recoma35E('R35e')
M19 = mat.M19_29Ga('M19')
#%% ROTOR
rotor = motor.PM_Rotor(dri=50, dm=10, dmp=3, alpha_m=60, p=2, OR=100)
rotor.draw()
rotor.set_materials(magnet=R35e, iron=M19)
#%% SCALE SCREEN AND SAVE
sim.zoom()
sim.save()