Introduction. Fortran Calculus programs are small optimization models of physical processes that are solved with sophisticated software based on automatic differentiation. The supporting structure is written is specific versions of Fortran, which require a very specific environment to run in. You can learn more about Fortran Calculus at www.metacalculus.com
Our Task. Our task here is to provide a way to create, manage, and submit Fortran Calculus models to the system and manage the results. A browser approach was taken, because the nature of the supporting environment is hidden from all and is widely accessible.
Screen Shot. The screenshot below gives you a sense of what we are trying to accomplish. We have a header, a footer, and a menu sidebar on the left. We have a central area (the dialog panel) which is used for communication with the user and the presentation of results.
Second Panel. There is also a second panel (not shown, because not yet there) to the right for additional results presentation. I am thinking that this new panel will show the results of runs, lists of things (models, runs, …), and documentation would be shown this new panel, particularly if I make the sidebar and the dialog panel narrower, leaving maybe 65 or 70% width for the main result panel. At present, the content panel is also in the dialog panel area.
Fortran Calculus Portal – Model Submission.
Fortran Calculus Programs. Fortran Calculus programs are a superset of fortran 77, called models here. An example of a Fortran Calculus Program, ACMOTOR.fc, is shown below.
GLOBAL ALL
PROBLEM ACMOTOR
DIMENSION CNS(7)
DYNAMIC BOTM,BND
CALL INPUT
CALL DESIGN
PRINT *,'--------------- INITIAL DESIGN ---------------'
CALL OUTPUT
FIND COILTRNS, ! Number of turns per coil
& SEPDIAM, ! Separating diameter
& STASLOTW, ! Stator slot opening width
& ROTSLOTW, ! Rotor slot opening width
& AIRGAP, ! Air gap
& STAT00TW, ! Stator tooth width
& STABAKIR, ! Stator back iron
& ROTTOOTW, ! Rotor tooth width
& ROTBAKIR, ! Rotor back iron
& STASLOTO, ! Stator slot opening depth
& ROTSLOTO, ! Rotor slot opening depth
& SLIP ! Slip
& IN DESIGN BY THOR(TCON)
& WITH BOUNDS BND AND LOWERS BOTM
& HOLDING CNS TO MAXIMIZE EFF
PRINT *,'---------------- OPTIMIZED DESIGN -----------------'
CALL OUTPUT
END
MODEL DESIGN
F1=231258.0438/COILTRNS
Q1=SEPDIAM*PI/56 : Q2=SEPDIAM*PI/69 : Q3=SEPDIAM*PI/28
C1=Q1/((Q1-STASLOTW)+(STASLOTW*(.7-(.036*(STASLOTW/AIRGAP)))))
C2=Q2/((Q2-ROTSLOTW)+(ROTSLOTW*(.7-(.036*(ROTSLOTW/AIRGAP)))))
CRNOL=F1*AIRGAP*C1*C2/(6.96*COILTRNS*Q3)
Q4=(STATOROD-STABAKIR-STABAKIR-SEPDIAM-.1)/2-.01
Q5=(SEPDIAM+Q4+.1)*PI/56-STAT00TW-.016 : A3=Q4*Q5 : Z1=7000*A3
Q6=COILTRNS*2/Z1: Z3=-2
Z4=32+Z3 : Q7=1.26**Z3*162 : Q8=64/1.26**Z3
Z5=STACKLEN+STACKLEN+PI*STATOROD/14
RDC=Z5*COILTRNS*28*Q7/12000
V1=(SEPDIAM-.06-ROTORID-ROTBAKIR-ROTBAKIR)/2
V2=(SEPDIAM-.06-V1)*PI/69-ROTTOOTW
A4=V1*V2 : R2=(.0133/A4)*(STACKLEN/12000)*U1
RROT=(56*COILTRNS)**2*R2/138 : R4=RROT
G3=3.2*(Q4/(3*Q5)+.03/(STASLOTW+Q5)+STASLOTO/STASLOTW)
G4=3.2*(V1/(3*V2)+.03/(ROTSLOTW+V2)+ROTSLOTO/ROTSLOTW)
G5=(1/C1+1/C2-1)**2*.26/AIRGAP
G6=(G3+G5*Q1)/56+(G4+G5*Q2)/69
XLEAK=XC*PI*COILTRNS**2*(.05+G6*STACKLEN) ! Leakage reactance
CRSTAL=115/(SQRT(((RDC+R4)**2)+XLEAK**2)) ! Stall current
CRFL=115/(SQRT(((RDC+R4/SLIP)**2)+XLEAK**2)) ! Full load current
STORQ=1.5792*(CRSTAL**2)*R4 ! Stall torque
RTORQ=1.5792*(CRFL**2)*R4/SLIP ! Running torque
P8=RTORQ*(1-SLIP)*1.264944649
P6=(CRSTAL**2)*(RDC+R4)
P7=(CRFL**2)*R4/SLIP
FLUX=(1.4*F1/(STAT00TW*STACKLEN))/6450 ! Flux density
B7=(SQRT(CRFL**2+CRNOL**2)*FLUX/CRNOL)/1.4
B2=.13*B7**1.9
B3=(((STATOROD**2-SEPDIAM**2)*PI/4)-56*A3)*0.28*STACKLEN
FELOSS=B3*B2 ! Iron losses
CULSTA=(B7*CRNOL)/FLUX)**2*RDC ! Stator copper losses
EFF=.5*P8/(P7+FELOSS/2+CULSTA) ! Efficiency -> maximize this
RAC=13225/FELOSS ! A.C. resistance
XMAG=115/CRNOL ! Magnetizing reactance
CULROT=CRFL*CRFL*RROT/STASLOTW ! Rotor copper losses
C Constraints
CNS(1)=STATOROD-.1-SEPDIAM ! Stator O.D >= Separation Diam +.1
CNS(2)=SEPDIAM-ROTORID+.1 ! Separation Diam >= Rotor I.D -.1
CNS(3)=((SEPDIAM*PI/69)-.035)-ROTTOOTW ! Rotor tooth geometry
CNS(4)=.5*(SEPDIAM-ROTORID)-.025-ROTBAKIR ! Rotor back iron geometry
CNS(5)=STORQ-60 ! Stall torque >= 60
CNS(6)=19-FLUX ! Flux density <= 19
CNS(7)=.05-SLIP ! Slip <= 5 percent
END
PROCEDURE INPUT
COILTRNS=29: STATOROD=5.11: SEPDIAM=4: ROTORID=2.875:
STASLOTW=.06: ROTSLOTW=.035: AIRGAP=.008: STAT00TW=.135:
STABAKIR=.15: ROTTOOTW=.11: ROTBAKIR=.47: Y1=2: XC=0.050176
STASLOTO=.035: ROTSLOTO=.015: SLIP=.03
STACKLEN=2: U1=2.6: PI=3.1415926536
=DATA(5,0,.035,.035,.008,.04,.06,0,0,.025,0,0)
=DATA(.01*COILTRNS,.05*SEPDIAM,.01*STASLOTW,.01*ROTSLOTW,
& .05*AIRGAP,.01*STAT00TW,.05*STABAKIR,.01*ROTTOOTW,.05*ROTBAKIR,
& .05*STASLOTO,.05*ROTSLOTO,.05*SLIP)
END
PROCEDURE OUTPUT
PRINT *,’ EFFICIENCY =’,EFF
PRINT *,’ STALL TORQUE =’,STORQ
PRINT *,’ RUNNING TORQUE =’,RTORQ
PRINT *,’ FLUX DENSITY =’,FLUX
PRINT *,’ IRON LOSSES =’,FELOSS
PRINT *,’ D.C. RESISTANCE =’,RDC
PRINT *,’ A.C. RESISTANCE =’,RAC
PRINT *,’ ROTOR RESISTANCE =’,RROT
PRINT *,’ LEAKAGE REACTANCE =’,XLEAK
PRINT *,’ MAGNETIZING REACTANCE =’,XMAG
PRINT *,’ STATOR COPPER LOSSES =’,CULSTA
PRINT *,’ ROTOR COPPER LOSSES =’,CULROT
PRINT *,’ NO LOAD CURRENT =’,CRNOL
PRINT *,’ FULL LOAD CURRENT =’,CRFL
PRINT *,’ STALL CURRENT =’,CRSTAL
END
CONTROLLER TCON(THOR)
SUMOUT=1
DETAIL=1
DETOUT=0
END
Fortran Calculus Program, ACMOTOR.FC
The Find Statement. The heart of the program is the FIND statement. It is analogous to the FIND in database SQL. It tells the system what it needs, not how to do it. In this case the FIND seeks the maximum efficiency in the motor design, allowing 12 design variables to vary, subject to some constraints.
The FC Process. To get a result we first must build an executable image. The fortran calculus program (acmotor.fc) gets translated to an acmotor.for program, which is then compiled with a Fortran compiler and linked to appropriate libraries, including the respective solver library, which contains the solution algorithm for this class of problems. We now have an acmotor.exe. This translate, compile, and link process produces a number of BUILD files. Combined with an optional .dat file, the exe produces a set of RUN output files. At present, the build/run process needs to be run in a controlled environment, at present, a SYSTEM thread on a ubuntu server (docker is being explored as a future solution; it also provides an alternate delivery mechanism for Fortran Calculus).
Portal Functions. The portal manages this process for a set of users. At present, the user creates a .fc file (and optional .dat) on his machine with his editor, and uses the portal to submit the file and get results. The results are viewed in the portal as web pages.
Portal Functions. So the portal must provide a way for a group of users to login, manage a set of models, submit jobs and get results. In addition, it should allow the users to manage their results, consult the system documentation, and feel a sense of community.
Functions In the Portal. If you review the above screen shot, starting with the left panel, you get a sense of where these functions are being dealt with. If you focus on the Submissions dialog you see how a run is submitted. Once a job is submitted, the job status is shown in the lower part of the left Menu panel. Starting at Initial, it cycles thru enqueued, started, completed. Plan to allow multiple jobs status’ to be shown. Action Cable is used to report the status.
Test-bed. The portal implementation is a test-bed, constantly changing, as I try to new things. I will make the portal source available on git (not the Fortran Calculus engine), at present it is still a private repository. Soon.
React. The big objects you see are React components: Header, Sidebar, Footer, and Content to name a few. More discussion of these and the rest in a later post.
Summary. In this post I have discussed what Fortran Calculus is and what functions the portal must provide to support it. I have tried to give an overview sense how React is being used to support the portal effort.
Next Up. Next up I plan to discuss a number of design decisions I had to make, specifically how do I:
- handle the styles,
- get login working,
- make ajax call for the submission,
- set up a job queue with Active Job,
- use Action Cable to report results back from Rails to the React front-end,
- deal with the documentation, which is html/image files
- deal with the result files, produced by a unix process