FV10 Excel Flux Tutorial en 2

Embed Size (px)

Citation preview

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    1/36

    Copyright February 2010

    FLUX Excel driving Flux

    Users Guide

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    2/36

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    3/36

    FLUX 10 Table of Content

    Table of Content

    1. Guide Overview ................................ ................................ ............................................. 1

    2. The Excel Interface................................ ................................ ........................................ 2

    3. Using Excel to drive Flux ................................ .............................................................. 4

    4. Start the Solving Process ................................ ............................................................... 6

    5. The Function initVBAFlux ............... ................ ................ ................ ............... ............. 7

    6. The Function StartVBAFlux ........................................................................................ 86.1. Initializing Flux ................................ ................................ ............................................ 96.2. Geometry Input ................................ ................................ ...........................................126.3. Modifying Radius R ................................ ..................................................................136.4. Meshing ................................ ................................................................ ..................... 146.5. Defining Physics ................................ ................................ ........................................156.6. Modifying the Current I ................................ ............................................................166.7. Solving ................................ ................................................................ ....................... 176.8. Analysis of solved problem ........................................................................................186.9. Closing the Project, Closing Flux ................................ ................................ ..............196.10. Analyzing Results ................................ ................................ .....................................20

    7. The function closeVBAFlux ................................................................ ....................... 21

    8. Attachments ................................................................ ................................ ................228.1. Python geometry input : geometry.py ................................................................ .238.2. Python meshing : meshing.py ................................ ................................ ..............248.3. Python physical properties : buildphys.py ...........................................................258.4. Python solving : solving.py ................................ ................................ .................268.5. Python postprocessing : postprocessing.py ..........................................................278.6. VBA code in the excel file ........................................................................................ 28

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    4/36

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    5/36

    FLUX 10

    Excel driving Flux 1

    1. Guide Overview

    Goal The goal of this document is to explain and demonstrate how to drive Fluxapplications using Excel 2003. A basic example is included to support thisgoal.

    ExampleSummary

    A copper wire infinite in length carries a current. The radius of the wire is R,the magnitude of the current is I .

    In our example, we will vary two parameters :The R value, radius of the wire (between 0 and 10 mm).The I value, magnitude of the current carried by the copper wire .

    The goal is :To measure the magnitude of the flux density B along a 25 mm long

    path extending from the center of the copper wire .

    Note on Theory The theoretical study of this example is easy to conduct using a close formsolution.

    The flux density is computed in a point M at a distance r from the center ofthe copper wire.

    The next two equations give the close form solution for the flux density :

    On the left when the computation point is located inside the copperwire,On the right when the computation point is outside the copper wire

    20

    R I r

    B Rr r

    I B Rr

    20

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    6/36

    FLUX 10

    Excel driving Flux2

    2. The Excel Interface

    Excel Interface The screen shot below shows the Excel spreadsheet used as an interface .(2a)

    2a

    Parametervariables

    The value contained in cell B5 and B6 can be changed:B5 : radius of the copper wire : R (mm)B6 : current carried by the wire : I (A)

    Solv eWithFlux

    When cell B5 and B6 are set, start Flux solving by selecting the menu item SOLVE WITH FLUX .

    Selecting SOLVE WITH FLUX runs a visual basic macro.The elements and actions executed by this macro are described in the nextsection.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    7/36

    FLUX 10

    Excel driving Flux 3

    Solving Process Once the solving process is started, cell A13 to A18 are updated in real timegiving a constant feedback on the activity of Flux and on the progression ofthe process.

    The coloring of the cells, yellow in our example, indicates the function activein the Flux process:

    Geometry input: cell A14.Meshing: cell A15.Physical properties: cell A16.Solving: cell A17 .Post processing: cell A18 .

    Post processing When the solving ends, the post processing updates the information in thetable with the current results.

    In our example, the values contained in cells E5 to E30 are updated by thevalues computed during the post processing. These cells always show theresults of the last solving process completed..

    The plot associated to the table of results is automatically updated by Excelwith the current results.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    8/36

    Flux10

    4 Excel driving Flux

    3. Using Excel to drive Flux

    Introduction Excel supports the development of VBA (Visual Basic for Applications) basedmacros .

    Flux supports Python based scripting, single commands or files.

    To drive Flux with Excel, python scripting of Flux, single commands or files,will be executed from VBA based macros in Excel.

    For the process to work correctly, the VBA macro from Excel must be able tolocate the associated python scripting files. We will adopt a naming conventionand chose a location for the files.

    This next section presents the strategy for driving Flux from Excel. It describesthe chosen location for all the necessary scripting files.

    Location of thefiles

    The VBA macro file and scripting files must be stored as follows:

    The main directory EXCEL_FLUX (any name not including extendedcharacters .*

    Holds the Excel file EXCEL_FLUX.xls (any name not includingextended characters ) of our spreadsheet and the directory w (set name).

    The directory w is where all the python scripting files needed for theexecution our process es are stored. The current example is developed using5 different python files, all called by the Excel VBA macro. The name ofthe python file can be any name not including extended characters.

    *Note: when using FLUX, paths leading to the file being execute d may notcontain extended character, and cannot contain any space s. This restrictionstands when using Excel to drive Flux (see: Flux Users Guide vol. 1 , sec4.1.1.pg.76 ).

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    9/36

    FLUX 10

    Excel driving Flux 5

    Driving FluxFrom Excel

    Steps followed when driving Flux from Excel, in the current example :

    Description ofthe Steps

    In our example, selecting the menu item SOLVE WITH FLUX starts amacro. The following ten steps are then executed:

    1. Initializ e Flux, open connection to Flux,2. Input problems geometry ,3. Read back value in cell B5 to modify value of R in geometry,4. Mesh domain5. Define physical properties for the problem, domain and regions ,6. Read back value in cell B6 to modify value of I,7. Solve problem,8. Compute results,9. Close project file, close Flux, import result into Excel,10. Process results in Excel and display variation curves.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    10/36

    Flux10

    6 Excel driving Flux

    4. Start the Solving Process

    VBA code Selecting the menu item SOLVE WITH FLUX starts the following VBAmacro

    Code of the macro :

    Filling the Cells The first steps accomplished by the macro associated to the menu itemSOLVE WITH FLUX are :

    - Color cell A13 yellow .- Color cells A14 A18 white .

    initVBAFlux Once the cells are colored, the macro starts the function initVBAFlux .

    initVBAFlux sets the environment variables and loads the required dll . Theenvironment variables are needed for the programs to find all necessary filesand code.

    StartVBAFlux The next function to run enables the driving of Flux from an Excel

    spreadsheet. StartVBAFlux will also execute all of the steps described in theprevious sections.

    closeVBAFlux The final function , closeVBAFlux ,will close Flux freeing the memory andunloading all of the dll called for during initialization.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    11/36

    FLUX 10

    Excel driving Flux 7

    5. The function initVBAFlux

    Introduction The function initVBAFlux initialize s all the environment variable necessaryfor Flux to run. It also loads all of the dll needed for the running of theapplication

    VBA Code The next section details the code included in initVBA :

    Location ofFlux

    The first step is to locate the directory where Flux was installed.

    This is done searching in the HKEY_LOCAL_MACHINE section of theregistry for the location where the executable of the active version of Fluxwas installed. At th e time o f updating this document, the current version is10.3.

    To proceed, we set the location where the address of the program we arelooking for is located (key_name), and the name of the value we are trying torecover.

    The value we are looking for is Flux_10.3 (subkey_name) located in thedirectory SOFTWARE/Cedrat/INSTALLPATH (key_name) of theHKEY_LOCAL_MACHINE section of the register.

    The function GetRegKeyValue returns into the variable initVBAFlux the

    location where the active version of Flux is installed.

    *Reminder: The registry can be accessed from the command regedit. Typeregedit in the run command of Windows.

    Loading the dll Once the location of the program is known, the dll needed to drive Fluxfrom Excel are loaded. In our example, we load resiflux.dll andflux_mp.dll.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    12/36

    Flux10

    8 Excel driving Flux

    6. The fu nction StartVBAFlux

    Introduction When the f unction InitVBAFlux is completed , the f unction StartVBAFluxstarts .

    This function runs the Python files and commands developed to drive Fluxfrom an Excel Spreadsheet

    VBA Code The code describing this function is to o long to be shown as a whole. It willbe explained in segments in the following sections.The sections will be:

    - 6.1. Initializing Flux- 6.2. Entering problems geometry- 6.3. Modifying radius R- 6.4. Meshing- 6.5. Setting physical properties- 6.6. Modifying current I- 6.7. Solving- 6.8. Analyzing solved problem- 6.9. Closing files, closing Flux- 6.10 . Analyzing results

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    13/36

    FLUX 10

    Excel driving Flux 9

    6.1. Initializing Flux

    Introduction After completing the first function and setting InitVBAFlux, other

    initialization functions are required to insure a proper performance to pilotFluxThis section spell s out the necessary steps to take before running the pythonfiles . The first py. file described is the file pertaining to the geometry input,geometry.py.

    Path to theProject

    The project files will be created in the directory w where all of the Pythonscripting files used to create the new project are stored.Note that the directory w is located in the same directory as the Excelspreadsheet used to drive Flux .The first step is to set variable holding the location where the project will besaved.The following instructions set the path to the project being created:

    Saving ExcelFile

    The second step saves the Excel spreadsheet being used. Saving the file isrequired to register the modification performed on cell s B5 and B6.

    The following instructions save the Excel spreadsheet:

    DecimalSeparator

    The decimal separator used by Excel (and the Microsoft programs moregenerally) depends on the native language support f unctions and the setlanguage for Windows.

    The French speaking users have selected , as decimal separator, the Englishspeaking users selected . as the decimal separator.

    To make the application usable by every one, we must identify the type ofdecimal separator used by the person running the Excel spreadsheet.

    The following code identifies the separator used :

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    14/36

    Flux10

    10 Excel driving Flux

    LicenseInitialization

    The third step sets and initializes the Flux license server (serverUid). Thisaction requires loading a specific file and choosing a working mode for thelicense.

    The following code sets and initializes the license server:

    The file used to set the license server is multiphys.wfg . The release mode(RELEASEMODE) is used for initialization.

    Setting upMemoryRequirements

    This step sets up and reserves the memory necessary to run the application. Italso sets the language used for the program,

    The following instructions set the memory and language :

    In our current example, we will use a numerical memory of 600 MB(NUMERICAL_MEMORY_LABEL). The English language is set by default(LANGUAGE_LABEL).

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    15/36

    FLUX 10

    Excel driving Flux 11

    Connection toLicense Server

    The last step of the initialization is the connection to the license server.

    The following code connects to the local license server of Flux:

    Note that the user must choose the version of Flux she/he wants to run. Fourchoices are available with version 10.3:

    Choice Description

    FLUX2D_10.3_32 2D problem solved on a 32 bitcomputer

    FLUX2D_10.3_64 2D problem solved on a 64 bit

    computerFLUX3D_10.3_32 3D problem solved on a 32 bitcomputer

    FLUX3D_10.3_64 3D problem solved on a 64 bitcomputer

    The user selects the location where the project will be created. In thecurrent example, the project will be created at the location contained in thecharacter string Path. This will be in the directory w located in thesame level in the directory tree than the Excel spreadsheet.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    16/36

    Flux10

    12 Excel driving Flux

    6.2. Geometry Input

    Introduction The geometry is created from a python file run from the VBA code associatedto the Excel spreadsheet.

    VBA Code The following code creates the geometry by running the Python script filegeometry.py :

    Filling Cell A14 Before the script geometry.py starts, the cell A14 is colored yellow. Thisindicates to the user that the geometry input is running.

    Python Code The detail of the code for the python script file geometry.py is in theattachment section of this document .

    This code includes :

    Creating a new project in Flux ,Defining a geometric parameter R with a default value of 0.5 mm ,Entering poin ts in the domain ,

    Entering li nes connecting the points,Building faces ,Saving project as : testcase_ini.FLU .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    17/36

    FLUX 10

    Excel driving Flux 13

    6.3. Modifying Radius R

    Introduction The radius R was entered as a geometric parameter .

    This geometric parameter is modified through a python command run fromthe VBA code associated to the Excel spreadsheet.

    PythonCommand

    The following python command modifies the value of parameter R setting itto 1:

    VBA Code The following code builds and calls the python command modifying theparameter R :

    VBA Code The code creates a character string Test set with the python command torun.

    Note that the value in cell B5 is read and converted in character string.

    In this character string, the function Replace() replaces , (decimal mark inFrench) by authorizing . as the decimal separator used by Flux as thedecimal point ..

    The next to last line in the code execute s the python command contained inthe character string test , modifying the value of the geometric parameterR .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    18/36

    Flux10

    14 Excel driving Flux

    6.4. Meshing

    Introduction The geometry is now modified and ready to be meshed.The Python script file meshing.py holds the instructions to perform themeshing.

    VBA Code The following VBA code handles the meshing :

    Coloring CellsA14 and A15

    Cell A14 is colored black and white and cell A15 is colored in yellow beforethe file meshing.py is called. These changes of color indicate theprogression of the proc ess in the Excel spreadsheet, from the completion of the MAKE GEOMETRY geometry to the start of the MESHING .

    Python Code The detail of the code in the python script file meshing.py is in theAttachment section of this document .

    This code includes :

    Defining the mesh weights ,Assigning the mesh weights to the geometric points ,Meshing the faces ,Saving the file as : meshed_geom .FLU .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    19/36

    FLUX 10

    Excel driving Flux 15

    6.5. Defining Physics

    Introduction The geometry being meshed, the Python script file buildphys.py is run todefine the physics of the problem.

    VBA Code The following VBA code handles the physics:

    Coloring CellsA15 and A16

    Cell A15 is colored b lack and white and cell A16 is colored in yellow beforethe file buildphysics.py is called. These changes of color indicate theprogression of the process in the Excel spreadsheet, from the completion ofthe MESHING to the start of the BUILD PHYSICS process .

    Python Code The detail of the code in the python script file buildphys.py is in theattachment section of this document.

    This code includes:

    Setting the Application, Magnetostatics, and the solver being called,Solver3D ,

    Creating an I/O parameter with a value 10 (Amp.) by default,Creating the surface regionsAssociating surface regions to geometric ,

    Saving file as : physbuilt.FLU .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    20/36

    Flux10

    16 Excel driving Flux

    6.6. Modifying the Current I

    Introduction The value of the current I is stored in an I/O parameter .

    The value of this parameter is modified through a python command run fromthe VBA code associated to the Excel spreadsheet.

    PythonCommand

    The following python command modifies the value of parameter I setting it to5:

    VBA Code The following code builds and calls the python command modifying theparameter I :

    VBA Code The code creates a character string Test set with the python command torun.

    Note that the value in cell B6 is read and converted in character string.

    In this character string, the function Replace() replaces , (decimal mark inFrench) by . as the decimal separator used by Flux is the decimal point ..

    The next to last line in the code execute s the python command contained inthe character string test , modifying the value of the I/O parameter I .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    21/36

    FLUX 10

    Excel driving Flux 17

    6.7. Solving

    Introduction The physics being completed, the Python script file solving.py is run tosolve the problem .

    The problem is solved for the value of the radius R in stored in cell B5 andthe value of the current I stored in cell B6.

    VBA Code The following VBA code handles the solving :

    Coloring CellsA16 and A17

    Cell A16 is colored black and white and cell A17 is colored in yellow beforethe file solving.py is called. These color changes indicate the progressionof the process in the Excel spreadsheet, transitioning from the completion ofthe BUILD PHYSICS to the start of the SOLVING process.

    Python Code The detail of the code in the python script file solving.py is in theAttachment section of this document.

    This code includes:

    Solving of the problem for the set values of the parameters R and I,Saving solved problem file as: solved.FLU .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    22/36

    Flux10

    18 Excel driving Flux

    6.8. Analy sis of solved problem

    Introduction The solving being completed, the Python script file postprocessing.py isrun to analyze the problem .

    The magnetic flux density is computed along a path 25 mm long , starting atthe center of the copper wire.

    VBA Code The following VBA code handles the post processing :

    Coloring CellsA17 and A18

    Cell A17 is colored b lack and white and cell A1 8 is colored in yellow beforethe file postprocess ing.py is called. These changes of color indicate theprogression of the process in the Excel spreadsheet, from the completion of SOLVING to the start of the POST PROCESSING .

    Python Code The detail of the code in the python script file postprocessing.py is in theattachment section of this document.

    This code includes:

    Creating a path 25 mm long starting at the center of the copper wirewith 25 subdivisions (1 subdivision every 1 mm),

    Plotting the curve of variation of the magnetic induction versusposition along the existing path,

    Exporting the computed values into the file Results.txt,Saving the project as postprocessed.FLU .

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    23/36

    FLUX 10

    Excel driving Flux 19

    6.9. Closing the Project, Closing Flux

    Introduction With postprocessing now completed, the Flux project and the program Fluxcan be closed.

    VBA Code The following VBA code handles the closing of fiel ds and programs :

    Coloring CellsA18 and A13

    Cells A17 and A 13 are colored b lack and white. These changes of colorindicate the progression of the process in the Excel spreadsheet, from thecompletion of the POSTPROCESSING to the end of processing.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    24/36

    Flux10

    20 Excel driving Flux

    6.10. Analyzing Results

    Introduction Flux having been closed, we can recover the results computed and storedwhen running postprocessing.py

    VBA Code This function recovers the values stored in the file Results.txt anddistribute s them into the cells E5 to E30 of the Excel spreadsheet. Theseresults are displayed either with a comma or a point as the decimal separator.

    The following code spells the post processing functions :

    Update of theresult table

    When the function is completed, the cells E5 to E30 are updated .

    The plot based on these values is also updated with the newly importedvalues.

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    25/36

    FLUX 10

    Excel driving Flux 21

    7. The fu nction closeVBAFlux

    Introduction The function closeVBAFlux closes the Flux environment and unloads all thedll loaded at the start of the macro.

    VBA Code The following code describes closeVBAFlux :

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    26/36

    Flux10

    22 Excel driving Flux

    8. Attachments

    Introduction This section holds all of the scripts and macros used to drive Flux from Excelin our example.

    Scripts andMacrosdeveloped

    All of the script and macro files are printed in the following subsections:

    - 8.1. Python geometry input geometry.py - 8.2. Python meshing meshing.py - 8.3. Python physical properties buildphys.py - 8.4. Python solving solving.py - 8.5. Python postprocessing postprocessing.py - 8.6. VBA code in the excel file

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    27/36

    FLUX 10

    Excel driving Flux 23

    8.1. Python File for geometry input: geometry.py

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    28/36

    Flux10

    24 Excel driving Flux

    8.2. Python File for meshing: meshing.py

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    29/36

    FLUX 10

    Excel driving Flux 25

    8.3. Python File for physical properties: buildphys.py

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    30/36

    Flux10

    26 Excel driving Flux

    8.4. Python file for solving: solving.py

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    31/36

    FLUX 10

    Excel driving Flux 27

    8.5. Python File for post processing: postprocessing.py

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    32/36

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    33/36

    FLUX 10

    Excel driving Flux 29

    StartVBAFlux()

    Sub StartVBAFlux()

    Dim i As LongDim row As IntegerDim lig As String

    Dim Test As String

    Dim interm As Double

    'project pathpath = ActiveWorkbook.path + " \ w"

    ' save Excel file

    ActiveWorkbook.Save

    ' Decimal separator "." o r ","DecimalSeparator = Application.International(xlDecimalSeparator)

    '############################################################################' INIT FLUX'############################################################################

    inst allFlux = initVBAFlux

    herror = FMP_init(installFlux + " \ bin \ multiphys.wfg", RELEASEMODE)If herror 0 Then GoTo ERROR

    '############################################################################' MEMORY'################################# ###########################################

    nbArg = 1herror = FMP_arg(NUMERICAL_MEMORY_LABEL, "600000000", nbArg, args)If herror 0 Then GoTo ERROR

    nbArg = nbArg + 1herror = FMP_arg(LANGUAGE_LABEL, "2", nbArg, args)If herror 0 Then GoTo ERROR

    '############################################################################' CONNEXION TO FLUX'########################################################## ##################

    herror = FMP_startLocaleServe r("FLUX2D_10.3_32", path, args, nbArg, serverUid)If herror 0 Then GoTo ERROR

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    34/36

    Flux10

    30 Excel driving Flux

    '############################################################################' GEOMETRY'############################################################################

    Range("A14").Interior.ColorIndex = 6

    herror = FMP_executeJythonCommand(serverUid, "executeBatchSpy('geometry.py')")If herror 0 Then GoTo ERROR

    '############################################################################' MODIFY RADIUS OF THE WIRE: R (mm)'############################################################################

    Test = "ParameterGeom['R'].expression=" + "'" + Replace(CStr(Range("B5")), ",", ".") + "'"

    herror = FMP_executeJythonCommand(serve rUid, Test)

    If herror 0 Then GoTo ERROR

    '############################################################################' MESHING'############################################################################

    Range("A14").Interior.ColorIndex = 0Range("A15").Interior.ColorIndex = 6

    herror = FMP_executeJythonCommand(serverUid, "executeBatchSpy('meshing.py')")If herror 0 Then GoTo ERROR

    '############################################################################' BUILD PHYSICS'############################################################################

    Range("A15").Interior.ColorIndex = 0Range("A16").Interior.ColorIndex = 6

    herror = FMP_executeJythonCommand(serverUid, "executeBatchSpy('buildphys.py')")If herror 0 Then GoTo ERROR

    '############################################################################' MODIFY CURRENT SUPPLIED THE WIRE: I (A)'############################################################################

    Test = "VariationParameter['I'].formula=" + "'" + Replace(CStr(Range("B6")), ",", ".") + "'"

    herror = FMP_executeJythonCommand(serverUid, Test)If herror 0 Then GoTo ERROR

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    35/36

    FLUX 10

    Excel driving Flux 31

    '############################################################################' SOLVE THE PROBLEM'############################################################################

    Range("A16").Interior.ColorIndex = 0Range("A17").Interior.ColorIndex = 6

    herror = FMP_executeJythonCommand(serverUid, " executeBatchSpy('solving.py')")If herror 0 Then GoTo ERROR

    '############################################################################' POSTPROCESSING'############################################################################

    Range("A17").Interior.ColorIndex = 0Range("A18").Interior.ColorIndex = 6

    herror = FMP_executeJythonCommand(serverUid, "executeBatchSpy('postprocessing.py')")If herror 0 Then GoTo ERROR

    '############################################################################' CLOSE PROJECT'############################################################################

    Range("A18").Interior.ColorIndex = 0Range("A13").Interior.ColorIndex = 0

    herror = FMP_executeJythonCo mmand(serverUid, "closeProject()")If herror 0 Then GoTo ERROR

    '############################################################################' CLOSE FLUX'############################################################################

    herror = FMP_stopServer(serverUid)If herror 0 Then GoTo ERROR

    '############################################################################' SHOW THE RESULTS'############################################################################

    numFile = FreeFile

    Open path + " \ Result.txt" For Input As #numFile

    i = 1

  • 8/12/2019 FV10 Excel Flux Tutorial en 2

    36/36

    Flux10

    If DecimalSeparator = "." Then ' excel usa

    While Not EOF(1)Line Input #1, ligrow = 4 + iRange("E" & CStr(r ow)) = Format(lig, "0.00E+0")interm = Range("E" & CStr(row))Range("E" & CStr(row)) = intermi = i + 1

    Wend

    Else ' excel fr

    While Not EOF(1)Line Input #1, ligrow = 4 + i

    Range("E" & CStr(row)) = Format(Replace(lig, ".", ","), "0.00E+0")interm = Range("E" & CStr(row))Range("E" & CStr(row)) = intermi = i + 1

    Wend

    End If

    Close #numFil e ' close the file

    TextBox1.Text = "diameter of the wire :" + vbTab + CStr(2 * Range("B5")) + vbTab + "mm"

    TextBox1.Text = TextBox1.Text + vbNewLine + "current :" + CStr(Range("B6")) + "A"GoTo NOERROR

    ERROR:ignore = FMP_getErrorMes sage(herror, txtError, maxSizeErrorMessage)ignore = FMP_freeError(herror)MsgBox "Error " & CStr(herror) & Chr(13) & txtError, vbCritical, "Flux Critical Error"ignore = FMP_stopServer(serverUid)

    NOERROR:

    End Sub