Esempio n. 1
0
        femm.mi_selectsegment(c1_x + width / 2, c1_y)
        femm.mi_setgroup(group)
        femm.mi_selectsegment(c2_x, c2_y)
        femm.mi_setgroup(group)
        femm.mi_selectsegment(c2_x, c2_y + length / 2)
        femm.mi_setgroup(group)
        femm.mi_selectsegment(c3_x, c3_y)
        femm.mi_setgroup(group)
        femm.mi_selectsegment(c3_x - width / 2, c3_y)
        femm.mi_setgroup(group)

        #femm.mi_clearselected()


femm.openfemm(0)
femm.opendocument(
    "setup.fem")  # Load a template that has all the required materials already
# pre-loaded, i.e when calling 'femm.mi_setblockprop('NdFeB 52 MGOe'.."
# This is how it knows where to get that property 'NdFeB 52 MGOe'
femm.mi_saveas(
    "temporary.fem"
)  # this changes the working file so that 'template.fem' is always whats in use

# This is Wire Gauge Data from MWS industries
# it may not line up exactly with the magnet wire in FEMM
# so it is good to be aware of this
# its 14 to 32 AWG
AWG_list = np.linspace(14, 32, 32 - 14 + 1).tolist()
OD_list = [
    0.06695, 0.05975, 0.0534, 0.0478, 0.04275, 0.0382, 0.03425, 0.0306,
    0.02735, 0.0246, 0.02205, 0.0197, 0.01765, 0.0159, 0.01425, 0.0128,
    0.01145, 0.0103, 0.00935
Esempio n. 2
0
fem_file_list = os.listdir(dir_run)
fem_file_list = [f for f in fem_file_list if '.fem' in f]

femm.openfemm(True)  # bHide
femm.callfemm_noeval('smartmesh(0)')

# this is essential to reduce elements counts from >50000 to ~20000.
print('mi_smartmesh is off')

for i in range(id_solver, len(fem_file_list), number_of_instances):

    output_file_name = dir_run + fem_file_list[i][:-4]

    if not os.path.exists(output_file_name + '.ans'):
        tic = time()
        femm.opendocument(output_file_name + '.fem')
        # femm.callfemm_noeval('mi_smartmesh(0)')
        try:
            # femm.mi_createmesh() # [useless]
            femm.mi_analyze(1)  # None for inherited. 1 for a minimized window,
            # print '[debug]', deg_per_step*i*number_of_instances, 'deg'
            # rotor_position = deg_per_step*i*number_of_instances / 180. * pi
            # write_Torque_and_B_data_to_file(output_file_name[-4:], exp(1j*rotor_position)) # this function is moved to FEMM_Solver.py as keep...
            if True:
                # call this after mi_analyze
                femm.mi_loadsolution()
                # Physical Amount on the Rotor
                femm.mo_groupselectblock(100)  # rotor iron
                femm.mo_groupselectblock(101)  # rotor bars
                Fx = femm.mo_blockintegral(
                    18
Esempio n. 3
0
import femm
import matplotlib.pyplot as plt

femm.openfemm()
femm.opendocument("coilgun.fem")
femm.mi_saveas("temp.fem")
femm.mi_seteditmode("group")
z = []
f = []
for n in range(0, 16):
    femm.mi_analyze()
    femm.mi_loadsolution()
    femm.mo_groupselectblock(1)
    fz = femm.mo_blockintegral(19)
    z.append(n * 0.1)
    f.append(fz)
    femm.mi_selectgroup(1)
    femm.mi_movetranslate(0, -0.1)
femm.closefemm()
plt.plot(z, f)
plt.ylabel('Force, N')
plt.xlabel('Offset, in')
plt.show()
Esempio n. 4
0
#     DEBUG_MODE = True

if DEBUG_MODE == False:
    number_of_instantces = int(sys.argv[1])
    dir_femm_temp = sys.argv[2]
    stack_length = float(sys.argv[3])
    VAREPSILON = 0.255  # difference between 1st and 2nd max torque slip frequencies
else:
    #debug
    number_of_instantces = 5
    dir_femm_temp = "D:/OneDrive - UW-Madison/c/csv_opti/run#114/femm_temp/"  # modify as expected
    stack_length = 186.4005899999999940
    VAREPSILON = 0.02

femm.openfemm(True)
femm.opendocument(dir_femm_temp + 'femm_temp.fem')

# here, the only variable for an individual is frequency, so pop = list of frequencies
freq_begin = 1.  # hz
freq_end = freq_begin + number_of_instantces - 1.  # 5 Hz

list_torque = []
list_slipfreq = []
list_solver_id = []
list_done_id = []
count_loop = 0
while True:
    # freq_step can be negative!
    freq_step = (freq_end - freq_begin) / (number_of_instantces - 1)

    count_done = len(list_done_id)
Esempio n. 5
0
femm.openfemm(True)  # bHide
# femm.smartmesh(0)
# femm.callfemm_noeval('smartmesh(0)')
# this is essential to reduce elements counts from >50000 to ~20000.
# print('mi_smartmesh is off')

bool_initialized = False
parallelResults = {}
for index in range(id_solver, ns, number_of_parallel_solve):

    if os.path.exists(project_file_name[:-4] + f'-{index:03d}.ans'):
        raise Exception('Previous .ans is not deleted!!!')

    tic = time()
    femm.opendocument(project_file_name[:-4] + f'-{index:03d}.fem')
    femm.mi_smartmesh(0)
    # femm.mi_saveas(f'temp-{id_solver}.fem')
    femm.mi_analyze(1)  # None for inherited. 1 for a minimized window,
    print(f'{index:02d}',
          project_file_name[:-4] +
          f'-{index:03d}.fem | Solving time: {time() - tic:.1f} s ',
          end='')
    femm.mi_loadsolution()
    # femm.mo_smooth('off') # flux smoothing algorithm is off

    if bool_initialized == False:
        bool_initialized = True
        # Record the initial mesh elements if the first time through the loop
        nn = int(femm.mo_numelements())
Esempio n. 6
0
    def open_previous(self, fname):

        fe.openfemm()
        fe.opendocument(fname)
        self.fname = fname
Esempio n. 7
0
femm.openfemm(True)  # bHide
# this is essential to reduce elements counts from >50000 to ~20000.
femm.callfemm_noeval('smartmesh(0)')
print 'smartmesh is off'

tic = time()
fem_file_path = dir_femm_temp + 'femm_temp_%d.fem' % (id_solver)

# # debug
# print fem_file_path
# # print dir_femm_temp
# os.system('pause')
# quit()

femm.opendocument(fem_file_path)
try:
    femm.mi_analyze(1)  # None for inherited. 1 for a minimized window,
    freq, torque = get_slipfreq_torque()
except Exception as error:
    print error.args
    raise error
femm.mi_close()
toc = time()
print 'id_solver=%d:' % (id_solver), toc - tic, 's'
femm.closefemm()

# removing files is left for manager to decide
# os.remove(fem_file_path)
# os.remove(fem_file_path[:-4]+'.ans')