Exemple #1
0
def add_pcbs(tg):
    '''Add primary and secondary side pcbs.'''
    # coordinates of the PCB on the primary side
    if tg.layers_primary == 1 or tg.layers_primary == 2:
        coords_pcb_prim = coords_of_rectangle(
            0, tg.height_dielectric + tg.height_copper + tg.height_gap,
            tg.radius_pcb, tg.height_pcb_core)
    elif tg.layers_primary == 4:
        coords_pcb_prim = coords_of_rectangle(
            0, tg.height_dielectric + tg.height_copper + tg.height_gap,
            tg.radius_pcb, tg.height_pcb_core + 2 * tg.height_pcb_prepreg +
            2 * tg.height_copper)
    else:
        print('Unknown number of layers on primary side')
        femm.closefemm()
        return (0, 0)

    # coordinates of the PCB on the secondary side
    if tg.layers_secondary == 1 or tg.layers_secondary == 2:
        coords_pcb_sec = coords_of_rectangle(0,
                                             -tg.height_copper - tg.height_gap,
                                             tg.radius_pcb,
                                             -tg.height_pcb_core)
    elif tg.layers_secondary == 4:
        coords_pcb_sec = coords_of_rectangle(
            0, -tg.height_copper - tg.height_gap, tg.radius_pcb,
            -tg.height_pcb_core - 2 * tg.height_pcb_prepreg -
            2 * tg.height_copper)
    else:
        print('Unknown number of layers on secondary side')
        femm.closefemm()
        return (0, 0)
    femm.mi_drawrectangle(*coords_pcb_prim)
    femm.mi_drawrectangle(*coords_pcb_sec)
Exemple #2
0
def add_isolation(tg):
    # coordinates of isolation disc
    coords_isolation = coords_of_rectangle(0, 0, tg.radius_dielectric,
                                           tg.height_dielectric)
    # coordinates of gel or liquid surrounding the transformer
    coords_gel = coords_of_rectangle(0, -tg.height_gel, tg.radius_gel,
                                     2 * tg.height_gel + tg.height_dielectric)
    femm.mi_drawrectangle(*coords_isolation)
    femm.mi_drawrectangle(*coords_gel)
Exemple #3
0
def draw_conductor(coords, in_conductor, label_name, label_dict):
    '''Draw a square conductor, set a block label in the middle of the
    conductor and add label properties.'''
    femm.mi_drawrectangle(*coords)

    label_coord = (average(
        (coords[0], coords[2])), average((coords[1], coords[3])))
    femm.mi_addblocklabel(*label_coord)
    femm.mi_selectlabel(*label_coord)
    if in_conductor == 1:
        femm.mi_setblockprop('copper', 1, 0, 'phase_prim', 0, 1, 1)
    elif in_conductor == 0:
        femm.mi_setblockprop('copper', 1, 0, 'phase_sec', 0, 1, 1)
    femm.mi_clearselected()
    label_dict[label_name] = label_coord
# boundary condition on the edge of the solution domain.

import femm
import matplotlib.pyplot as plt

femm.openfemm()  # create an instance of femm without GUI

# problem definition
femm.newdocument(0)  # create new magnetic problem preprocessor document

femm.mi_probdef(
    0, 'millimeters', 'axi', 1.e-8, 0, 30
)  # Define the problem type. Magnetostatic; Units of mm; Axisymmetric; Precision of 10^(-8) for the linear solver; a placeholder of 0 for the depth dimension, and an angle constraint of 30 degrees

# geometry definition
femm.mi_drawrectangle(6, 0, 15, 5)  # draw a rectangle for the ring magnet;

# boundaries conditions
femm.mi_makeABC()  # simulate an open boundary condition

# materials properties
femm.mi_addblocklabel(1, 1)  # air block (airbox)
femm.mi_addblocklabel(10, 3)  # ring block (neodymium)

femm.mi_getmaterial(
    'Air')  # fetches the material called air from the materials library
femm.mi_getmaterial('N48')

femm.mi_selectlabel(10, 3)  # assign the material to the block
femm.mi_setblockprop(
    'N48', 0, 1, '<None>', 90, 0, 0
Exemple #5
0
import femm
import matplotlib.pyplot as plt

# The package must be initialized with the openfemm command.
femm.openfemm();

# We need to create a new Magnetostatics document to work on.
femm.newdocument(0);

# Define the problem type.  Magnetostatic; Units of mm; Axisymmetric; 
# Precision of 10^(-8) for the linear solver; a placeholder of 0 for 
# the depth dimension, and an angle constraint of 30 degrees
femm.mi_probdef(0, 'millimeters', 'axi', 1.e-8, 0, 30);

# Draw a rectangle for the steel bar on the axis;
femm.mi_drawrectangle(0, -40, 10, 40);

# Draw a rectangle for the coil;
femm.mi_drawrectangle(50, -50, 100, 50);

# Define an "open" boundary condition using the built-in function:
femm.mi_makeABC()

# Add block labels, one to each the steel, coil, and air regions.
femm.mi_addblocklabel(5,0);
femm.mi_addblocklabel(75,0);
femm.mi_addblocklabel(30,100);

# Add some block labels materials properties
femm.mi_addmaterial('Air', 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0);
femm.mi_addmaterial('Coil', 1, 1, 0, 0, 58*0.65, 0, 0, 1, 0, 0, 0);
    def simulate(self):
        self.__updateDimensions()
        # open FEMM
        femm.openfemm()
        femm.main_maximize()

        # True Steady State
        # new Magnetostatics document

        femm.newdocument(0)

        # Define the problem type.  Magnetostatic; Units of mm; 2D planar;
        # Precision of 10^(-8) for the linear solver; a placeholder of 0 for
        # the depth dimension, and an angle constraint of 30 degrees
        femm.mi_probdef(0, 'millimeters', 'planar', 1.e-8, 0, 30)

        # Import Materials
        femm.mi_getmaterial('Air')
        femm.mi_getmaterial(self.magnetType)
        femm.mi_getmaterial(self.windingType)

        # Draw geometry
        # Coil
        for coil in range(0, self.numStators):
            corner = Vector(coil * (self.coilLength + self.coilBufferLength), 0)
            femm.mi_drawrectangle(corner.x, corner.y, corner.x + self.coilLength, corner.y + self.pcbThickness)
            femm.mi_addblocklabel(corner.x + self.coilLength / 2, corner.y + self.pcbThickness / 2)
            femm.mi_selectlabel(corner.x + self.coilLength / 2, corner.y + self.pcbThickness / 2)
            femm.mi_setblockprop(self.windingType, 1, 0, '<None>', 0, 0, self.numWindings)


        # # Upper Rotor
        for magnet in range(0, self.numPoles):
            corner = Vector(magnet * (self.magnetLength + self.magnetBufferLength), self.pcbThickness + self.airGap)
            femm.mi_drawrectangle(corner.x, corner.y, corner.x + self.magnetLength, corner.y + self.rotorThickness)
            femm.mi_addblocklabel(corner.x + self.magnetLength / 2, corner.y + self.rotorThickness / 2)
            femm.mi_selectlabel(corner.x + self.magnetLength / 2, corner.y + self.rotorThickness / 2)
            if magnet % 2 == 0:
                femm.mi_setblockprop(self.magnetType, 1, 0, '<None>', 90, 0, 0)
            else:
                femm.mi_setblockprop(self.magnetType, 1, 0, '<None>', -90, 0, 0)
            if magnet == int(self.numPoles / 2):
                self.testPoint = Vector(corner.x, 0 + self.pcbThickness / 2)

        # Lower Rotor
        for magnet in range(0, self.numPoles):
            corner = Vector(magnet * (self.magnetLength + self.magnetBufferLength), -self.airGap)
            femm.mi_drawrectangle(corner.x, corner.y, corner.x + self.magnetLength, corner.y - self.rotorThickness)
            femm.mi_addblocklabel(corner.x + self.magnetLength / 2, corner.y - self.rotorThickness / 2)
            femm.mi_selectlabel(corner.x + self.magnetLength / 2, corner.y - self.rotorThickness / 2)
            if magnet % 2 == 0:
                femm.mi_setblockprop(self.magnetType, 1, 0, '<None>', 90, 0, 0)
            else:
                femm.mi_setblockprop(self.magnetType, 1, 0, '<None>', -90, 0, 0)

        # Define an "open" boundary condition using the built-in function:
        # Add air block label outside machine
        femm.mi_makeABC()
        airLabel = Vector((self.numStators / 2) * (self.coilLength + self.coilBufferLength), 5 * (self.rotorThickness + self.airGap))
        femm.mi_addblocklabel(airLabel.x, airLabel.y)
        femm.mi_selectlabel(airLabel.x, airLabel.y)
        femm.mi_setblockprop('Air', 1, 0, '<None>', 0, 0, 0)

        # We have to give the geometry a name before we can analyze it.
        femm.mi_saveas('alternatorSim.fem')

        # Now,analyze the problem and load the solution when the analysis is finished
        femm.mi_analyze()
        femm.mi_loadsolution()

        # Now, the finished input geometry can be displayed.
        # femm.mo_zoom(self.testPoint.x - 2 * self.coilLength, self.testPoint.y - self.coilLength,
        #              self.testPoint.x + 2 * self.coilLength,
        #              self.testPoint.y + self.coilLength)
        # femm.mo_showdensityplot(1, 0, 1, 0, 'mag')

        self.fluxDensity = self.getFlux()
# Set up problem type. This sets up problem as an axisymmetric problem with units of micrometers
femm.mi_probdef(0, 'micrometers', 'axi', 10**(-8), 0, minangle, 0)

# Add materials to our workspace
femm.mi_addmaterial('magnet', 1.05, 1.05, 922850, 0, 0.667, 0, 0, 1, 0, 0, 0)
femm.mi_addmaterial('air', 1, 1, 0)
femm.mi_addmaterial('36awgcopper', 1, 1, 0,
                    i / ((wire_thickness / 2)**(2) * 3.14), 58, 0, 0, 1, 3, 0,
                    0, 1, 127)
#change J applied current

#define circuit with current i in series
femm.mi_addcircprop('spiral', i, 1)

#draw and label magnet wall
femm.mi_drawrectangle(0, wall_distance, wall_radius,
                      (wall_distance + wall_thickness))
femm.mi_addblocklabel(wall_radius / 2, (wall_distance + wall_thickness / 2))
femm.mi_selectlabel(wall_radius / 2, (wall_distance + wall_thickness / 2))
femm.mi_setblockprop('magnet', automesh, meshsize, 0, 270, 0, 0)
femm.mi_clearselected()

#draw and label spiral cross section
while (r < outer_radius):
    if (r == inner_radius):
        pass
    else:
        r = r + wire_spacing

    inner_edge = r
    outer_edge = r + wire_thickness
    femm.mi_drawarc(inner_edge, 0, outer_edge, 0, 180, EXPERIMENT)
Exemple #8
0
    # True Steady State
    # New MagnetoStatics Document
    femm.newdocument(0)

    # Define the problem type.  60 Hz; Units of inches; Axisymmetric;
    # Precision of 10^(-8) for the linear solver; a placeholder of 0 for
    # the depth dimension, and an angle constraint of 30 degrees
    femm.mi_probdef(FREQ, 'inches', 'axi', 1.e-8, 0, 30)

    # Import materials
    femm.mi_getmaterial('Air')
    femm.mi_getmaterial('Pure Iron')
    femm.mi_getmaterial('30 AWG')

    # Draw Rectangles
    femm.mi_drawrectangle(0, d - 0.2, 0.04,
                          d + 0.2)  # Iron Core 0.6" height 0.04" inner radius
    femm.mi_drawrectangle(
        0.05, -0.1, 0.1,
        0.1)  # Primary Coil 0.2" Height, 0.05" inner radius, 0.1" outer radius
    femm.mi_drawrectangle(
        0.05, 0.11, 0.1, 0.31
    )  # Top Secondary Coil 0.2" Height, 0.05" inner radius, 0.1" outer radius
    femm.mi_drawrectangle(
        0.05, -0.31, 0.1, -0.11
    )  # Bottom Secondary Coil 0.2" Height, 0.05" inner radius, 0.1" outer radius

    # Add Block Labels, materials, and circuits

    # Air Label
    femm.mi_addblocklabel(0.3, 0)
    femm.mi_selectlabel(0.3, 0)
    def creation_geometrie(self):
        """Méthode permettant de générer la géométrie"""

        # Dessin d'un rectangle (xmin,ymin,xmax,ymax)
        femm.mi_drawrectangle(-self.largeur / 2, -self.hauteur / 2,
                              self.largeur / 2, self.hauteur / 2)

        # Dessin de points (x,y)
        femm.mi_addnode(self.l_dent / 2, self.entrefer / 2)
        femm.mi_addnode(-self.l_dent / 2, self.entrefer / 2)
        femm.mi_addnode(self.l_dent / 2, -self.entrefer / 2)
        femm.mi_addnode(-self.l_dent / 2, -self.entrefer / 2)

        femm.mi_addnode(self.l_dent / 2, self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addnode(-self.l_dent / 2, self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addnode(self.l_dent / 2, -self.hauteur / 2 + self.l_dent / 2)
        femm.mi_addnode(-self.l_dent / 2, -self.hauteur / 2 + self.l_dent / 2)

        femm.mi_addnode(self.largeur / 2 - self.l_dent / 2,
                        self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addnode(-self.largeur / 2 + self.l_dent / 2,
                        self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addnode(self.largeur / 2 - self.l_dent / 2,
                        -self.hauteur / 2 + self.l_dent / 2)
        femm.mi_addnode(-self.largeur / 2 + self.l_dent / 2,
                        -self.hauteur / 2 + self.l_dent / 2)

        # Dessin des lignes (x1,y1,x2,y2)
        femm.mi_addsegment(self.l_dent / 2, self.entrefer / 2,
                           -self.l_dent / 2, self.entrefer / 2)
        femm.mi_addsegment(self.l_dent / 2, -self.entrefer / 2,
                           -self.l_dent / 2, -self.entrefer / 2)

        femm.mi_addsegment(self.l_dent / 2, self.entrefer / 2, self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addsegment(-self.l_dent / 2, self.entrefer / 2,
                           -self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addsegment(self.l_dent / 2, -self.entrefer / 2,
                           self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)
        femm.mi_addsegment(-self.l_dent / 2, -self.entrefer / 2,
                           -self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)

        femm.mi_addsegment(self.l_dent / 2, self.hauteur / 2 - self.l_dent / 2,
                           self.largeur / 2 - self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addsegment(-self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2,
                           -self.largeur / 2 + self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2)
        femm.mi_addsegment(self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2,
                           self.largeur / 2 - self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)
        femm.mi_addsegment(-self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2,
                           -self.largeur / 2 + self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)

        femm.mi_addsegment(self.largeur / 2 - self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2,
                           self.largeur / 2 - self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)
        femm.mi_addsegment(-self.largeur / 2 + self.l_dent / 2,
                           self.hauteur / 2 - self.l_dent / 2,
                           -self.largeur / 2 + self.l_dent / 2,
                           -self.hauteur / 2 + self.l_dent / 2)

        femm.mi_addsegment(self.l_dent / 2, self.entrefer / 2, self.l_dent / 2,
                           -self.entrefer / 2)
        femm.mi_addsegment(-self.l_dent / 2, self.entrefer / 2,
                           -self.l_dent / 2, -self.entrefer / 2)
Exemple #10
0
import femm
import matplotlib.pyplot as plt

# The package must be initialized with the openfemm command.
femm.openfemm()

# We need to create a new Magnetostatics document to work on.
femm.newdocument(0)

# Define the problem type.  Magnetostatic; Units of mm; Axisymmetric;
# Precision of 10^(-8) for the linear solver; a placeholder of 0 for
# the depth dimension, and an angle constraint of 30 degrees
femm.mi_probdef(0, 'millimeters', 'axi', 1.e-8, 0, 30)

# Draw a rectangle for the steel bar on the axis;
femm.mi_drawrectangle(0, -40, 10, 40)

# Define an "open" boundary condition using the built-in function:
femm.mi_makeABC()

# Add block labels, one to each the steel, coil, and air regions.
femm.mi_addblocklabel(5, 0)
femm.mi_addblocklabel(35, 15)

# Add some block labels materials properties
femm.mi_addmaterial('Air', 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0)
femm.mi_addmaterial('LinearIron', 2100, 2100, 0, 0, 0, 0, 0, 1, 0, 0, 0)

# Apply the materials to the appropriate block labels
femm.mi_selectlabel(5, 0)
femm.mi_setblockprop('LinearIron', 0, 1, '<None>', 0, 0, 0)