Exemple #1
0
    def create_model_with_dxf(self, model, magnets, magnetMat):
        dxfname = model.dxffile.get('name', None)
        if not dxfname:
            logger.error('Name of dxf-file expected')
            sys.exit(1)

        if dxfname.split('.')[-1] not in ('dxf'):
            dxfname += '.dxf'
        if not os.path.isfile(dxfname):
            logger.error('File {} not found'.format(dxfname))
            sys.exit(1)

        params = {}
        params['split'] = model.dxffile.get('split', False)
        params['show_plots'] = model.dxffile.get('plot', False)
        params['write_fsl'] = True
        params['airgap'] = model.dxffile.get('airgap', 0.0)
        params['inner_name'] = 'inner_tmp'
        params['outer_name'] = 'outer_tmp'

        conv = converter(dxfname, **params)

        model.set_value('poles', conv.get('num_poles'))
        model.set_value('outer_diam', conv.get('dy1') * 1e-3)
        model.set_value('bore_diam', conv.get('da1') * 1e-3)
        model.set_value('inner_diam', conv.get('dy2') * 1e-3)
        model.set_value('airgap',
                        (conv.get('da1') - conv.get('da2')) / 2 / 1e3)

        stator = getattr(model, 'stator', None)
        if stator is None:
            setattr(model, 'stator', {})
        model.stator['num_slots'] = conv.get('tot_num_slot')
        model.stator['num_slots_gen'] = conv.get('num_sl_gen')
        filename = conv.get('filename_stator', None)
        if not filename:
            logger.error('Filename of stator not found')
            sys.exit(1)
        model.stator[filename.split('.')[0]] = {}

        rotor = getattr(model, 'magnet', None)
        if rotor is None:
            setattr(model, 'magnet', {})
        filename = conv.get('filename_rotor', None)
        if not filename:
            logger.error('Filename of rotor not found')
            sys.exit(1)
        model.magnet[filename.split('.')[0]] = {}

        return self.create_new_model(model) + \
            self.create_cu_losses(model) + \
            self.create_stator_model(model) + \
            self.create_gen_winding(model) + \
            self.create_magnet(model, magnetMat) + \
            self.create_magnet_model(model) + \
            self.mesh_airgap(model) + \
            self.create_permanent_magnets(model) + \
            self.create_connect_models(model)
Exemple #2
0
    def prepare_stator_dxf2fsl(self, model):
        templ = model.statortype()
        if not os.path.isfile(templ + '.dxf'):
            return
        if os.path.isfile(templ + '.fsl'):
            return  # ok (fsl already available)

        params = {}
        params['split'] = model.stator[templ].get('split', False)
        params['show_plots'] = model.stator[templ].get('plot', False)
        params['write_fsl'] = True
        params['airgap'] = -1.0
        params['part'] = ('stator', model.stator[templ].get('position'))
        params['inner_name'] = 'tmp'
        params['outer_name'] = 'tmp'
        conv = converter(templ + '.dxf', **params)

        model.stator['num_slots'] = conv.get('tot_num_slot')
        self.set_diameter_parameter(model, conv)
        self.fsl_stator = True
        del model.stator[templ]
        model.stator[conv['filename']] = dict()
Exemple #3
0
            if args.airgap2 > 0.0:
                print("Airgap is set from {} to {}".format(
                    args.airgap, args.airgap2))
            else:
                print("Airgap is set to {}".format(args.airgap))
        else:
            if args.airgap2 > 0.0:
                logger.info("Airgap is set from {} to {}".format(
                    args.airgap, args.airgap2))
            else:
                logger.info("Airgap is set to {}".format(args.airgap))

    if not args.write_fsl:
        if not args.show_plots:
            args.write_fsl = True

    converter(
        args.dxfile,  # DXF-Filename
        rtol=args.rtol,  # relative pickdist toleranz
        atol=args.atol,  # absolute pickdist toleranz
        symtol=args.sym_tolerance,
        split=args.split,
        inner_name=args.inner,
        outer_name=args.outer,
        airgap=args.airgap,
        airgap2=args.airgap2,
        view_only=args.view,
        show_plots=args.show_plots,
        write_fsl=args.write_fsl,
        debug_mode=args.debug)