Sie sind auf Seite 1von 21
Flux10 Macro creation and application management

Flux10

Flux10 Macro creation and application management

Macro creation and application management

Flux10 Macro creation and application management

Macros

Table of Contents

Flux10

Forward…

…………………

3

1.Creation of a New Macro

….4

1.1 Objective:

4

1.2 Macro Components and creation stages

4

1.3 Example…………………………………………………………………………… 5

1.4 Structure…………………………………………………………………………….…6

1.5 Process………………………………………………………………………………

1.5.1 Create.py file……………………………………………….……………… 7

1.5.2 Create.txt file

1.5.3 Load the macro…………………….………………………………………11

1.5.4 Run the macro…………

…………………………………………………12

1.6 Create_Line.pfm………………………………………………………………….12-14

7

… 10

2.Management and execution of macros

…….………………………

……………………

…15

Overview…………………………………………………………………………………15

2.1 Management of macros………………………………………………………15

2.2 Macro interface with Flux……………………………………………………16

2.3 Running a macro………………………………………………… …………16

3.

Macros included with Flux V10.X

17

Overview

17

3.1 Table of Macros……………………………………………………………………17

3.1.1 Geometry macros…………………………………………………

3.1.2 Change of materials macros……………………………………….………….18

3.1.3 Import materials macros……………………………………………

…….17

……18

3.1.4 Physics macros………………………………………………………

3.1.5 Post Processing macros………………………………………………………20

19

……

This document outlines the process of Macro creation, installation, activation and execution in Flux V10 software, New 2D and 3D

Macros

Forward

Flux10

Overview:

This document gives a concise, step by step, explanation of macro creation and execution for use in Flux V10.X software.

A macro is a Pyflux function with parameters. The macro is a command script, added to the Flux application interface to streamline repetitive operations.

Macro's can be created by users. Several Macro's are shipped with the program and can be found in the C:\Cedrat\Extensions\Macros directory once the program is installed. Macros are described in Chapter 3 of this document.

A macro can be activated and executed automatically once it is loaded into the

A

macro can be activated and executed automatically once it is loaded into the

Flux interface.

A macro groups several Pyflux commands in a given order and enables the user to

A

macro groups several Pyflux commands in a given order and enables the user to

input one or more parameters and execute a series of predefined actions.

A macro is loaded using the Extension/Macro menu item. When a macro is loaded, its

A macro is loaded using the Extension/Macro menu item. When a macro is loaded, its associated icon is added to the bar of icons. The macro is also added to the data tree.( see page 16)

Advantages of using Macros:

Macros make repetitive tasks automatic . make repetitive tasks automatic.

Macros allow the input of geometric items from a table or spreadsheet.of using Macros: Macros make repetitive tasks automatic . Macros customize Flux for specific applications. Macros

Macros customize Flux for specific applications.the input of geometric items from a table or spreadsheet. Macros automate treatment for each phase

Macros automate treatment for each phase of project development.allow the input of geometric items from a table or spreadsheet. Macros customize Flux for specific

Macros

Flux10

1. Creation of a New Macro

Introduction

This Chapter will give a general overview along with a specific example of writing a Macro.

Contents

This chapter contains the following topics:

Topic

See Page

1.1 Objective:

4

1.2 Macro Components and creation stages

4

1.3 Example

5

1.4 Structure

6

1.5 Process: Create_point.pfm

7-13

1.6 Create_line.pfm

13

1.1 Objective: Write, load and execute a basic Macro in Flux.

The objective is to show on a simple example how to write and use a macro. This macro makes repetitive tasks, such as entering the coordinates during the creation of points, easier.

1.2 Macro components:

The Macro consists of a .PFM file containing an icon (.gif) and . py command function Macro consists of a .PFM file containing an icon (.gif) and .py command function, located by default in the C:\Cedrat\Extensions\Macros directory.

The names of these files should be the same for all three extensions.by default in the C:\Cedrat\Extensions\Macros directory. a) test1.PFM (contains .gif and .py files) b) test1.gif c)

a) test1.PFM (contains .gif and .py files)

b) test1.gif

c) test1.py

(contains .gif and .py files) b) test1.gif c) test1.py b. a. To write python command and

b.

(contains .gif and .py files) b) test1.gif c) test1.py b. a. To write python command and
(contains .gif and .py files) b) test1.gif c) test1.py b. a. To write python command and

a. To write python command and parameterize the command using the macro format see Sec. 1.4.

c.

Macros

Flux10

 

Stages

Description of file

Required

Of

applications

Creation

for macro creation

1

Creation of the macro definition .py file

Text editor (see Idle Editor download link

pg.6)

Creation of the image-formatted file for the associated icon (optional but recommended)

Image editor (.gif) Paint, Clip-Art etc.

2

Loading of the macro into the Flux project

Flux

3

Execution of the macro

Flux

1.3 Example

The Create_point.PFM macro is designed to automatically create 3D points starting from a series of coordinates previously saved in a text file.

Description

The file name and the coordinate system for definition of the points are selected by the user during the execution of the macro.

* The definition of a macro requires good knowledge of Pyflux commands and basic macro programming.

To define the macro in the Pyflux language

Step

Action

1

Type a header of executable Flux program

2

Describe input parameters of the macro

3

Define the Polypoint3D parameterized function in the PyFlux language

4

Save the file of the macro under the name Polypoint3D.py in the Polypoint3D.PFM directory.

1.4 Structure

The structure of a file defining the macro (*.py) is presented in the example below.

Macros

Flux10

 

The Idle .py editor is the most efficient tool to use for writing pyflux scripts.

To download the python tutorial and IDLE .py editor.

 

(useful when constructing .py files and macros)

The macro can be broken into 3 sections.

Part

Description

1

Header of an executable Flux program

2

Description of input parameters of the macro

3

Definition of a parameterized function in the PyFlux language

(1) Program

The Flux program header is compulsory. It specifies which Flux program (2D and/or 3D) will execute the macro and its version*.

header

* The indicated version can correspond to the current software version or a previous version.

(2) Description of parameters

This second section deals with the description of the input parameters of the macro.

For each parameter it is necessary to define:

A parameter name

A parameter name

A Pyflux type

A Pyflux type

Minimal and maximal values corresponding to

Minimal and maximal values corresponding to

the

data structure

A default value or a keyword None

A default value or a keyword None

A label associated to the parameter

A label associated to the parameter

(this label appears in the dialogue box for the running macro)

(3)

Parameterized

function

This third section contains the description of the parameterized function.

For this function it is necessary to define:

Macros

1.5 Process:

Flux10

Macros 1.5 Process: Flux10 A function name (= name of the macro) Input parameters of the

A function name (= name of the macro)

Input parameters of the de function Body of the function (PyFlux instructions) By default these files are kept in the C:\Cedrat\Extensions directory. You can create a new directory for them and navigate to the location when you activate the macro.

and navigate to the location when you activate the macro. 1.5.1 Create the .py file We
and navigate to the location when you activate the macro. 1.5.1 Create the .py file We

1.5.1 Create the .py file

We will examine the steps necessary in creating the

Create_point.PFM for use in the macro interface of Flux 3D.

We will examine the steps necessary in creating the Create_point.PFM for use in the macro interface

Macros

Flux10

Macro “.py “ input

Function description: *(Python IDLE used in this example IDLE download: http://www.python.org ; color coding is using “IDLE Classic” color setting)*

  1) Header #! This statement designates the compatible Flux Version. (The macro may be
 

1)

Header #! This statement designates the compatible Flux Version. (The macro may be executed from PreFlu 3D 9.31 through the present release) red=python item

History: Date and Author M/Y/D

Allows direct use of python debugger module elements. (pydb) Python Debugger (IDLE download)

Allows direct use of python debugger module elements. (pydb) Python Debugger (IDLE download)

Python keywords in orange**.

Python definitions in blue.

A class is created to handle: User Exceptions

”””

””” attributes definition in green

**def: user function

A class is created to handle: User Exceptions ””” ””” attributes definition in green **def: user

Page

8

Macros

Flux10

Macros Flux10 2) Description of input parameters for the macro:(main attribute definition) @param filename: Attribute

2)

Description of input parameters for the macro:(main attribute definition)

@param filename: Attribute definition for the input field.

File: Required input source in Pyflux syntax (Pyflux type)

1 1 : input range (min-max)

File defining points : (field interface label)

None : (default entry)

points : (field interface label) None : (default entry) @ param coordSys: Attribute definition for the

@ param coordSys: Attribute definition for the inputs required in a field

CoordSys: Required input source in Pyflux syntax(Pyflux type)

1 1: input range (min,max)

Coordinate system: (field interface label)

[‘XYZ’] :(default entry for coordinate system)

label) [‘XYZ’] :(default entry for coordinate system) 3a)Parameterized Function interface: Definition of the
label) [‘XYZ’] :(default entry for coordinate system) 3a)Parameterized Function interface: Definition of the
label) [‘XYZ’] :(default entry for coordinate system) 3a)Parameterized Function interface: Definition of the

3a)Parameterized Function interface: Definition of the Polypoint3D function interface with 2 parameters (keyword/definition/functions) (parameters that define the file name and the coordinate system)

Page

9

Macros

Flux10

Example of input file: Note inserted describing the creation and set-up of the point coordinate
Example of input file:
Note inserted describing the creation and set-up of
the point coordinate input file with an example of
the formatted input (.txt file format).
(n+1) refers to the Id x y z heading line and
subsequent point and coordinate lines in 4
columns.

*This input file will be requested from the macro interface once the macro is loaded. Input files are not necessary for all macros. This is dependent on the input format for the input parameters. In this case geometric coordinates are required and are input using the .txt file.

The point.txt file is presented as follows:

Locate this in your project folder and navigate to it using the macro input interface.

folder and navigate to it using the macro input interface. To save the coordinates of points

To save the coordinates of points from Flux to a in text file:

save the coordinates of points from Flux to a in text file: type data in the

type data in the form of a table

(You can export geometric .py data directly from Flux 2d and 3D as a .txt or excel export).

directly from Flux 2d and 3D as a .txt or excel export). extract point data and
directly from Flux 2d and 3D as a .txt or excel export). extract point data and

extract point data and save the file under the name point.txt

Page 10

Macros

Flux10

3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation
3b) Python parameterized command: Creation of the variable f. reference for the file input/output creation

3b) Python parameterized command:

Creation of the variable f.

reference for the file input/output

creation of a for loop to iterate through all of the file lines

# Get coordinate command followed by:

The creation of variable coordinates which takes values from the list of strings for each file line

**purple commands indicate built in function

creation of the points with the following characteristics:

color = whitecreation of the points with the following characteristics: visibility = visible coordinates = inputs coordinates from

visibility = visiblethe points with the following characteristics: color = white coordinates = inputs coordinates from points.txt (0,

coordinates = inputs coordinates from points.txt (0, 0, 0); (3, 0, 0); (3, 2, 0); (2, 2, 0); (2, 1, 0); (1, 1, 0); (1, 2, 0); (0, 2, 0)points with the following characteristics: color = white visibility = visible nature = standard User Exception

nature = standard(0, 0, 0); (3, 0, 0); (3, 2, 0); (2, 2, 0); (2, 1, 0); (1,

User Exception definitionfrom points.txt (0, 0, 0); (3, 0, 0); (3, 2, 0); (2, 2, 0); (2, 1,

*You can check for proper formatting of the python file by using Run/Check Module in the Idle editor. For more information on IDLE go to the IDLE Help menu.

Place the .py and .gif files in a .PFM folder of the same nameFor more information on IDLE go to the IDLE Help menu. Place in the default in

Place in the default in the C:\Cedrat\Extensions\Macros directorymore information on IDLE go to the IDLE Help menu. Place the .py and .gif files

Page 11

Macros

1.5.2

Load the

Macro

Macros 1.5.2 Load the Macro 1.5.3 Run the macro Flux10 Select the Load command in the

1.5.3

Run the macro

Flux10

Select the Load command in the Extensions/ Macro menu or in the contextual menu of the macro

Macro menu or in the contextual menu of the macro Click on the Run command in

Click on the Run command in the contextual menu of the macroMacro menu or in the contextual menu of the macro Fill out the fields in the

Fill out the fields in the dialog box Polypoint3DClick on the Run command in the contextual menu of the macro After running the Polypoint3D

After running the Polypoint3D macro, the user has the following 8 points in his Flux project (0, 0, 0), (3, 0, 0), (3, 2, 0), (2, 2, 0), (2, 1, 0), (1, 1, 0), (1, 2, 0), (0, 2, 0).Click on the Run command in the contextual menu of the macro Fill out the fields

points in his Flux project (0, 0, 0), (3, 0, 0), (3, 2, 0), (2, 2,

Macros

Flux10

1.6

Create_line.pfm

Following the execution of the Create_point.pfm Load the Create_line.pfm to connect the points to form a cubic base.

Create_line.pfm to connect the points to form a cubic base. Create Line .PFM Follows same format
Create_line.pfm to connect the points to form a cubic base. Create Line .PFM Follows same format
Create_line.pfm to connect the points to form a cubic base. Create Line .PFM Follows same format
Create_line.pfm to connect the points to form a cubic base. Create Line .PFM Follows same format

Create Line .PFM Follows same format as Create_point.PFM

Macros

Flux10

#1 Header #2 parameter input interface definition Example of input file
#1
Header
#2 parameter
input interface
definition
Example of
input file

#3 a) Parameterized Function interface

interface definition Example of input file #3 a) Parameterized Function interface #3 b) Pyflux command script

#3 b) Pyflux command script

Macros

Flux10

2. Management and execution of Macros

Overview

This section describes the steps required to manage and execute existing macros.

Contents

This section contains the following topics:

Topic

See Page

Management of macros, Flux commands

15

Macro interface with Flux

16

Running a macro

16

2.1 Management

of macros

The user can load, unload and reload macros within the project.

The Flux commands for the management of macros are located in the Extensions menu. (see screenshots)

Load, Run, Unload, Update.

for the management of macros are located in the Extensions menu. ( see screenshots) Load, Run,
for the management of macros are located in the Extensions menu. ( see screenshots) Load, Run,

Macros

Flux10

2.2 Macro

interface with

Flux

All the macros loaded into the Flux project appear:

in the Extensions/ Macros node of the data treeFlux All the macros loaded into the Flux project appear: in the toolbar (icons) The loaded

in the toolbar (icons)appear: in the Extensions/ Macros node of the data tree The loaded macros are saved with

The loaded macros are saved with the project.

in

the toolbar

Macro will appear in the General Data Tree

in the toolbar Macro will appear in the General Data Tree 2.3 Running a macro The
in the toolbar Macro will appear in the General Data Tree 2.3 Running a macro The
in the toolbar Macro will appear in the General Data Tree 2.3 Running a macro The

2.3

Running a

macro

The user can run a macro by using the Run command from the macro contextual menu or by clicking on the corresponding icon. The dialog box associated to the types of parameters is then displayed.

or by clicking on the corresponding icon. The dialog box associated to the types of parameters

Macros

Flux10

3. Macros included with Flux V10.X

Overview

The following is a list of Macros included in Flux V10 for 2D and 3D with a brief description of the application

Contents

This section contains the following topics:

Topic

See Page

Table of macros contained in Flux 10 and description

17

Geometry Macros

17

Change Materials Macros

18

Import Materials Macros

18

Physics Macros

19

Post Processing Macros

20

3.1 Table of Macros in Flux 2D and 3D

3.1.1

Geometry Macros

Description

Flux New 2d/3D

 

Create_Points.PFM

Executable macro that creates cubic point configuration from a .txt file input in 3D(example in .py file)

Create_Lines.PFM

Executable macro creates lines .txt file input(example in .py file

3.1.2

Change Materials Macros

 

Flux New 2d

 

RegLin_ChangeMater.PF

Changes the material

M

associated with a line region

RegSurf_ChangeMater.PF

Changes the material

M

associated with a surface region

Flux 3D

 

RegVol_ChangeMater.PF

Changes the material

M

associated to a Volume region.

Macros

Flux10

3.1.3 Import Materials Macros

Description cont.

Import_RCP_TTableFunc

Imports a table to describe material properties: Temp. Vs. Specific heat (RhoCP (rho density [kg/m³] cp specific heat capacity [J/kg/K]))

tion.PFM

Import_KT_IsotropicTTa

Imports a table to describe: Isotropic Thermal Conductivity

bleFunction.PFM

Import_JE_TTableFunctio

Imports a table to describe: Temp Vs. Rho (density)

n.PFM

Import_BH_NonlinearSpli

Imports a property table to describe a non- linear BH curve

ne.PFM

Import_BH_MagnetNonli

A macro to import the B(H) values of a Magnet Nonlinear Spline

nearSpline.PFM

Import_BH_LinearTTable

Imports properties for the B(H) values of a Linear Temp. Table Function

Function.PFM

Macros

Flux10

3.1.4 Physics Macros

Descriptions

Flux New 2d

 

assignSquirrelCage.PFM

This macro will facilitate assigning solid conductors defined in the circuit module with the squirrel component to existing regions.

BHSplinetoexcel.PFM

This macro allows creating an EXCEL file from B(H) curve of spline type. It also allows computing the differential permeability (slope).

Flux 3d

 

Import_ComposedCoil.PF

This macro will

M

create a non-meshed composed coil from coordinates imported from a .txt file (example in .PFM)

Create_ComposedCoil_Sp

This macro will create a helical composed non-meshed coil with the input of path coordinate .txt file (example in .PFM)

ire.PFM

Macros

Flux10

3.1.5

Post Processing

Descriptions

Macros

Flux New 2d

 

AnimationArrowsFaceRe

This macro creates image files (.png) for arrows displayed on face region(s) at different phases( in the range from 0 to 360°)

gionAC.PFM

animationColorShadeFace

This macro creates .png files for use in creating an animation in 2D (displays color shade quantity on face region)

Region.PFM

animationIsolineFaceRegi

This macro creates files for animation in 2D (display quantity on face region) .png

onAC.PFM

ColorShadeFaceRegion.P

This macro display the gradient of B on all the face regions

FM

IsolinesVectorPotential.P

This macro allows displaying the isolines of the magnetic vector potential on face region(s)

FM

Flux 3d

 

animationIsolineVolumeR

This macro creates files (.png) for animation in 3D (display Isolines in volume region)

egionAC.PFM

AnimationArrowsVolume

This macro creates image files (.png) of arrows displayed on volume region(s) for different phases in the range from 0 to 360°

RegionAC.PFM

animationColorShadeVolu

This macro creates files (.png) for animation of the color shade of B in 3D (display quantity on volume region)

meRegionAC.PFM

Create_Sensors.PFM

Create sensors from coordinates imported from a .txt file

Macros

Flux10