Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Calculus-level Coding Overview

16 views

Published on

NASA's Apollo Space team developed the first Calculus-level language, Slang, to solve complex math equations with minimum effort and time. Slang was renamed Prose and was introduced to the industrial world in 1974. Today, a (free) Windows version is available for the FortranCalculus language/compiler.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Calculus-level Coding Overview

  1. 1. Improve Math Models &Improve Math Models & Increase ProductivityIncrease Productivity By Phil BrubakerBy Phil Brubaker forfor Scientists,Scientists, Engineers & ManagementEngineers & Management Optimal Designs EnterpriseOptimal Designs Enterprise goal-driven.netgoal-driven.net
  2. 2. Improve Models &Improve Models & Increase ProductivityIncrease Productivity AgendaAgenda Design ObjectivesDesign Objectives Language BackgroundLanguage Background Example CodeExample Code Optimization of OptimizationsOptimization of Optimizations
  3. 3. Code DefinitionCode Definition OptimizationOptimization == SimulationSimulation ++ Objective (Function)Objective (Function)
  4. 4. Why OptimizationWhy Optimization over Simulation?over Simulation? Maximize Parameter Tolerance for Mfg.Maximize Parameter Tolerance for Mfg. Solutions are at min./max. locations whereSolutions are at min./max. locations where their partial derivatives = 0 & thus allow largesttheir partial derivatives = 0 & thus allow largest delta errors.delta errors. Minimize # of Executions for a solutionMinimize # of Executions for a solution
  5. 5. IntroductionIntroduction toto FortranCalculusFortranCalculus a Calculus-level Computer Languagea Calculus-level Computer Language 1974 First Commercial Release (PROSE)1974 First Commercial Release (PROSE) I taught PROSE in 1975-79.I taught PROSE in 1975-79. Solved problems within 4 hours (each)Solved problems within 4 hours (each) Present version is FortranCalculusPresent version is FortranCalculus Main obstacle: no design objectiveMain obstacle: no design objective
  6. 6. Objective-Driven EngineeringObjective-Driven Engineering What are yourWhat are your Goals/ObjectivesGoals/Objectives forfor a given Project?a given Project?
  7. 7. What are you building?What are you building? Mr. Arithmetic Mr. Algebra Mr. CalculusMr. Arithmetic Mr. Algebra Mr. Calculus ------------------- --------------- ----------------------------------- --------------- ---------------- Slide Rule Simulate OptimizeSlide Rule Simulate Optimize
  8. 8. Objective-Driven CutsObjective-Driven Cuts Sawmill's operation Objective for cutting log?Objective for cutting log?
  9. 9. Objective-Driven CutsObjective-Driven Cuts Sawmill's operation Objective for cutting log?Objective for cutting log? Maximize company's profitsMaximize company's profits Minimize pollutionMinimize pollution Minimize 'waste'Minimize 'waste' Maximize 2" x 4"sMaximize 2" x 4"s
  10. 10. Sawmill's operationSawmill's operation Parameters to consider:Parameters to consider: Log-to-lumber Processing:Log-to-lumber Processing: Size of logSize of log: diameter, length, taper, knots, etc.: diameter, length, taper, knots, etc. Time requiredTime required to: cut log, sharpen blades, lubricateto: cut log, sharpen blades, lubricate machinery, etc.machinery, etc. Strength or flexibilityStrength or flexibility desired of various sizes.desired of various sizes. InventoryInventory Market trendsMarket trends Objective-Driven CutsObjective-Driven Cuts
  11. 11. Chaotic Design ProcessChaotic Design Process Control BoxControl Box Bingo, a design!Bingo, a design!
  12. 12. Objective-Driven DesignObjective-Driven Design Surveillance Design Objective:Surveillance Design Objective: Maximize surveillance coverageMaximize surveillance coverage Minimize number of satellitesMinimize number of satellites Solution? (Not realistic; Objective needs work.)Solution? (Not realistic; Objective needs work.)
  13. 13. Objective-Driven DesignObjective-Driven Design Thin-Film-Head (TFH) for Magnetic RecordingThin-Film-Head (TFH) for Magnetic Recording TFH with coilTFH with coil Disc platter cross-sectionDisc platter cross-section Typical Readback PulseTypical Readback Pulse Optimum pulse shapeOptimum pulse shape versusversus
  14. 14. Objective-Driven DesignObjective-Driven Design Thin-Film-Head (TFH) for Magnetic Recording Design Objective?Design Objective? Maximize ProfitMaximize Profit Maximize Pulse SymmetryMaximize Pulse Symmetry Minimize Pulse WidthMinimize Pulse Width Minimize PollutionMinimize Pollution Maximize User SatisfactionMaximize User Satisfaction ?????? Solution: Determine TFH geometrySolution: Determine TFH geometry parametersparameters A, B, CA, B, C, etc. to achieve objective., etc. to achieve objective.
  15. 15. Objective-Driven DesignObjective-Driven Design Matched Filter for Magnetic RecordingMatched Filter for Magnetic Recording Electrical FilterElectrical Filter Yin(t) ==>Yin(t) ==> TransferTransfer FunctionFunction -------------------------- H(s)H(s) ==> Yout(t)==> Yout(t) versusversus Typical Input Pulse, Yin(t)Typical Input Pulse, Yin(t) Desired Output Pulse, Yout(t)Desired Output Pulse, Yout(t)
  16. 16. Objective-Driven DesignObjective-Driven Design Matched Filter for Magnetic RecordingMatched Filter for Magnetic Recording Results:Results: Textbook problem solved in 4 hoursTextbook problem solved in 4 hours Design required 2 years to acquire a true practicalDesign required 2 years to acquire a true practical objective functionobjective function Development time droppedDevelopment time dropped from 12 to 1 weekfrom 12 to 1 week Design was mathematically optimalDesign was mathematically optimal
  17. 17. Explicit & Implicit EquationsExplicit & Implicit Equations Inverse & Optimization ProblemsInverse & Optimization Problems Differential EquationsDifferential Equations IVP & BVP ProblemsIVP & BVP Problems Limits & ConstraintsLimits & Constraints FortranCalculusFortranCalculus LanguageLanguage Example CodeExample Code AgendaAgenda
  18. 18. Complete Example CodeComplete Example Code global allglobal all problem rocket ! three stage rocket design optimizationproblem rocket ! three stage rocket design optimization dimension spi(3),spivac(3),tburn(3),thrust(3),xip(3),wprop(3),dimension spi(3),spivac(3),tburn(3),thrust(3),xip(3),wprop(3), & ratio(3),wstage(3),strfac(3),delv(3),g(2)& ratio(3),wstage(3),strfac(3),delv(3),g(2) thrust(1)=350 : thrust(2)=1500 : thrust(3)=4100thrust(1)=350 : thrust(2)=1500 : thrust(3)=4100 tburn(1)=110 : tburn(2)=100 : tburn(3)=180tburn(1)=110 : tburn(2)=100 : tburn(3)=180 xip(1)=5d-3 : xip(2)=0 : xip(3)=0xip(1)=5d-3 : xip(2)=0 : xip(3)=0 spivac(1)=315 : spivac(2)=315 : spivac(3)=315spivac(1)=315 : spivac(2)=315 : spivac(3)=315 FINDFIND thrust(1),thrust(2),tburn(2),tburn(3); in stages;thrust(1),thrust(2),tburn(2),tburn(3); in stages; * by Hera; reporting dlvtot,tbtot; to minimize weight* by Hera; reporting dlvtot,tbtot; to minimize weight endend model stagesmodel stages FindFind thrust(3),tburn(1); in eqns; by Ajax; to match gthrust(3),tburn(1); in eqns; by Ajax; to match g endend model eqnsmodel eqns data gc,wpayld,delvip,tbip/32.174,50,2.8e4,400/data gc,wpayld,delvip,tbip/32.174,50,2.8e4,400/ dlvtot=0 : tbtot=0dlvtot=0 : tbtot=0 weight=wpayldweight=wpayld do 10 i=1,3do 10 i=1,3 spi(i)=spivac(i)*(1-xip(i))spi(i)=spivac(i)*(1-xip(i)) wprop(i)=thrust(i)*tburn(i)/spi(i)wprop(i)=thrust(i)*tburn(i)/spi(i) wstage(i)=0.0234*thrust(i)+wprop(i)+1.255*wprop(i)**0.704+4wstage(i)=0.0234*thrust(i)+wprop(i)+1.255*wprop(i)**0.704+4 strfac(i)=wprop(i)/wstage(i)strfac(i)=wprop(i)/wstage(i) weight=weight+wstage(i)weight=weight+wstage(i) ratio(i)=weight/(weight-wprop(i))ratio(i)=weight/(weight-wprop(i)) delv(i)=gc*spi(i)*log(ratio(i))delv(i)=gc*spi(i)*log(ratio(i)) dlvtot=dlvtot+delv(i)dlvtot=dlvtot+delv(i) tbtot=tbtot+tburn(i)tbtot=tbtot+tburn(i) 10 continue10 continue g(1)=dlvtot-delvip ! total delta v constraintg(1)=dlvtot-delvip ! total delta v constraint g(2)=tbtot-tbipg(2)=tbtot-tbip ! total burn time constraint! total burn time constraint endend MathMath ModelModel
  19. 19. Example Convergence ReportExample Convergence Report o o oo o o LOOP NUMBER .... [INITIAL] 5 6LOOP NUMBER .... [INITIAL] 5 6 UNKNOWNSUNKNOWNS A ( 1) 1.000000E+00 4.432149E-01 3.737358E-01A ( 1) 1.000000E+00 4.432149E-01 3.737358E-01 B ( 1) 1.000000E+00 4.040783E+00 4.284183E+00B ( 1) 1.000000E+00 4.040783E+00 4.284183E+00 C ( 1) 1.230000E+02 4.305000E+02 4.920000E+02C ( 1) 1.230000E+02 4.305000E+02 4.920000E+02 OBJECTIVEOBJECTIVE ERRSUM 8.189812E+00ERRSUM 8.189812E+00 4.870502E-02 3.879211E-024.870502E-02 3.879211E-02 o o oo o o
  20. 20. Explicit EquationExplicit Equation o o oo o o FindFind A,B,CA,B,C; In; In EngineEngine; to ...; to ... o o oo o o ModelModel EngineEngine Y = Function( X;Y = Function( X; A,B,CA,B,C)) End ModelEnd Model MathMath ModelModel
  21. 21. Inverse ProblemInverse Problem o o oo o o Ydesired = 123.456 ! target valueYdesired = 123.456 ! target value FindFind A,B,CA,B,C; In; In EngineEngine; to; to MatchMatch GG o o oo o o ModelModel EngineEngine Y = Function( X;Y = Function( X; A,B,CA,B,C)) GG = Ydesired - Y= Ydesired - Y End ModelEnd Model
  22. 22. Optimization ProblemOptimization Problem o o oo o o FindFind A,B,CA,B,C; In; In EngineEngine; to; to MinimizeMinimize GG o o oo o o ModelModel EngineEngine GG = Y - Function( X;= Y - Function( X; A,B,CA,B,C)) End ModelEnd Model
  23. 23. Explicit Differential EquationsExplicit Differential Equations o o oo o o InitiateInitiate ISISISIS; For; For EngineEngine;; EquationsEquations Y2Dot/YDot, YDot/Y; ...Y2Dot/YDot, YDot/Y; ... o o oo o o IntegrateIntegrate EngineEngine; By; By ISISISIS o o oo o o ModelModel EngineEngine Y2DotY2Dot = Function( YDot, Y= Function( YDot, Y)) End ModelEnd Model
  24. 24. Initial Value ProblemsInitial Value Problems Explicit EquationsExplicit Equations InitiateInitiate YDot = 123.456 : Y2Dot = 234.567 : Y3Dot = ...YDot = 123.456 : Y2Dot = 234.567 : Y3Dot = ... ! Initial Values! Initial Values o o oo o o IntegrateIntegrate ...... o o oo o o Model ...Model ... YnDotYnDot = Function( Yn= Function( Yn11Dot, ... , YDot, YDot, ... , YDot, Y)) End ModelEnd Model
  25. 25. Boundary Value ProblemsBoundary Value Problems Explicit EquationsExplicit Equations o o oo o o FindFind YDot0, ... To MatchYDot0, ... To Match HH o o oo o o IntegrateIntegrate ...... o o oo o o HH = (Y0 - Y0_desired)**2 += (Y0 - Y0_desired)**2 + (Ylast - Ylast_desired)**2 ! boundary values(Ylast - Ylast_desired)**2 ! boundary values
  26. 26. Limits & Inequality ConstraintsLimits & Inequality Constraints o o oo o o Find ...Find ... WithWith LowersLowers ... And... And UppersUppers ... Holding ...... Holding ... o o oo o o
  27. 27. TweakTweak TweakTweak TweakTweak o o oo o o FindFind E,F,GE,F,G ...... ! Add to any problem! Add to any problem o o oo o o ! in order to tweak! in order to tweak E,F,GE,F,G ......
  28. 28. Nested Calculus ProcessesNested Calculus Processes o o oo o o FindFind ...... o o oo o o IntegrateIntegrate ...... o o oo o o IntegrateIntegrate ...... o o oo o o FindFind ......
  29. 29. FindFind Statement:Statement: Key for Calculus-level language Simplicity!Key for Calculus-level language Simplicity! ..
  30. 30. FindFind independentsindependents; In; In modelNamemodelName; By; By solversolver;; Find StatementFind Statement The Workhorse of languageThe Workhorse of language {{With|And} Lower{s}{{With|And} Lower{s} bottomsbottoms;};} {{With|And} Upper{s}{{With|And} Upper{s} topstops;};} {{With|And} Holding{{With|And} Holding inequalitiesinequalities;};} {{With|And} Matching{{With|And} Matching equalitiesequalities;};} ToTo criterioncriterion
  31. 31. Handling ConstraintsHandling Constraints o o oo o o Find a, b, c, etc.; In MyXYZmodel;Find a, b, c, etc.; In MyXYZmodel; with Holdingwith Holding h1, h2, h3h1, h2, h3,, o o oo o o EndEnd Model MyXYZmodelModel MyXYZmodel h1h1 = a - 4 * w + 100 != a - 4 * w + 100 ! for a > 4w - 100for a > 4w - 100 EndEnd
  32. 32. User Control of SolverUser Control of Solver o o oo o o Find a, b, c, etc.; In ABCmodel;Find a, b, c, etc.; In ABCmodel; By Solver(By Solver( MyCtrlMyCtrl); To); To o o oo o o EndEnd ControllerController MyCtrlMyCtrl( Solver)( Solver) Summary=1 ! produces a summary reportSummary=1 ! produces a summary report Detail=n ! produce a detailed report everyDetail=n ! produce a detailed report every ! 'n' iterations plus 1st & last.! 'n' iterations plus 1st & last. o o oo o o EndEnd
  33. 33. Integrating Differential EquationsIntegrating Differential Equations o o oo o o InitiateInitiate solversolver;; {{With} Flag{{With} Flag flagflag;};} {{With|And} Lower{s}{{With|And} Lower{s} bottomsbottoms;};} {{With|And} Upper{s}{{With|And} Upper{s} topstops;};} ForFor modelmodel; Equations; Equations rates/statesrates/states;; OfOf independentindependent; Step; Step incrementincrement; To; To limitlimit o o oo o o IntegrateIntegrate modelmodel
  34. 34. How are problems solved?How are problems solved? o o oo o o FindFind ...... byby 'Solver''Solver' o o oo o o where 'Solver' is a numerical methodwhere 'Solver' is a numerical method using Automatic Differention tousing Automatic Differention to calculate necessary derivatives. Thecalculate necessary derivatives. The available solvers are in a FC library; e.g.available solvers are in a FC library; e.g. Ajax, Mars, Neptune, etc.Ajax, Mars, Neptune, etc.
  35. 35. Objective-Driven EngineeringObjective-Driven Engineering OptimizationsOptimizations withinwithin OptimizationOptimization A nesting exampleA nesting example
  36. 36. Automotive Mfg. CompanyAutomotive Mfg. Company Optimization LevelsOptimization Levels Level 1 Company Company Design Dept. Mfg. Dept. Engine Mfg. Power Train Engine Design Power Train Level 2 Dept.s Level 3 Groups Optimal Designs EnterpriseOptimal Designs Enterprise goal-driven.netgoal-driven.net
  37. 37. Design Department'sDesign Department's Engine Design CodeEngine Design Code (Get Iron, Rubber, etc values from Co. database)(Get Iron, Rubber, etc values from Co. database) FindFind EngineSizeEngineSize, etc; In, etc; In EngineEngine; to Minimize; to Minimize PollutionPollution; and Maximize; and Maximize GasEfficiencyGasEfficiency...... o o oo o o ModelModel EngineEngine HorsePower = ... Iron ...HorsePower = ... Iron ... EngineSizeEngineSize ...... GasEfficiencyGasEfficiency = ... TerrainType ... HorsePower= ... TerrainType ... HorsePower PollutionPollution = ... CarWeight ... HorsePower ...= ... CarWeight ... HorsePower ... GasInEfficiency ... RubberGasInEfficiency ... Rubber End ModelEnd Model Level 3
  38. 38. Design Department's CodeDesign Department's Code (Get Iron, Rubber, etc values from Co. database)(Get Iron, Rubber, etc values from Co. database) FindFind CarWeightCarWeight, etc; In, etc; In CarDesignCarDesign; to Minimize; to Minimize CarPollutionCarPollution; and Maximize; and Maximize CarSafetyCarSafety ...... o o oo o o ModelModel CarDesignCarDesign Call EngineDesignCall EngineDesign !! Another OptimizationAnother Optimization Call PowerTrainCall PowerTrain !! Another OptimizationAnother Optimization CarPollutionCarPollution = ...= ... CarWeightCarWeight ... HorsePower ...... HorsePower ... GasInEfficiency ... Rubber ... CoalGasInEfficiency ... Rubber ... Coal CarSafetyCarSafety = ... Iron ... CarWeight ...= ... Iron ... CarWeight ... End ModelEnd Model Level 2
  39. 39. Company's CodeCompany's Code (Get present Iron, Rubber, etc values from Co. database)(Get present Iron, Rubber, etc values from Co. database) FindFind IronIron,, RubberRubber, etc; In, etc; In CompanyCompany; to Minimize; to Minimize Time2MarketTime2Market; and Maximize; and Maximize ProfitProfit ...... o o oo o o ModelModel CompanyCompany Call DesignCall Design !! Another OptimizationAnother Optimization Call ManufacturingCall Manufacturing !! Another OptimizationAnother Optimization Call SalesCall Sales !! Another OptimizationAnother Optimization Time2MarketTime2Market = ...= ... IronIron ...... ProfitProfit = ...= ... IronIron ...... RubberRubber ... Coal ...... Coal ... End ModelEnd Model Level 1
  40. 40. Code for OptimizationsCode for Optimizations Level 3 Code ... GroupsLevel 3 Code ... Groups Most Important ... fundamental equationsMost Important ... fundamental equations Can Run IndependentlyCan Run Independently Contains Math Models to Simulate Design/Mfg.Contains Math Models to Simulate Design/Mfg. Level 2 Code ... Dept.sLevel 2 Code ... Dept.s Runs Latest Level 3 code tooRuns Latest Level 3 code too Level 1 Code ... CompanyLevel 1 Code ... Company Runs Latest of All LevRuns Latest of All Levelsels All L 3s All L 2s L 1 Some L 3s l L 2 1 L 3 Easy to UpdateEasy to Update
  41. 41. Building ApplicationsBuilding Applications o o oo o o Find a, b, c, etc.;Find a, b, c, etc.; o o oo o o call MyOutputcall MyOutput EndEnd ModelModel xxxxxx ! derivatives! derivatives ActiveActive o o oo o o EndEnd SubroutineSubroutine MyOutputMyOutput ! derivatives! derivatives NOT ActiveNOT Active o o oo o o EndEnd
  42. 42. Variable DefinitionsVariable Definitions 64-bit words ... Local by default64-bit words ... Local by default GlobalGlobal classesclasses {; In{; In proceduresprocedures }} Global AllGlobal All Global realGlobal real Global real; in abc, def, xyzGlobal real; in abc, def, xyz
  43. 43. Input Variable AccuracyInput Variable Accuracy for Optimization runsfor Optimization runs pi = 3.14pi = 3.14 ! Slide rule accuracy, not good!! Slide rule accuracy, not good! abc = 1.2345678abc = 1.2345678 ! 8+ digits, Good! 8+ digits, Good def = x.xx...xdef = x.xx...x ! 15 digits, excellent!! 15 digits, excellent!
  44. 44. Code for XY_PlotsCode for XY_Plotsoooooo C =============== Example code for writing ODE-XYplot files ===============C =============== Example code for writing ODE-XYplot files =============== @aplot( 1)@aplot( 1) ! any 6 char.s or less for 'od-plt' ... temp filename! any 6 char.s or less for 'od-plt' ... temp filename endend procedure aplot( iplot)procedure aplot( iplot) character*8 fn*12, string*66, date7, time7character*8 fn*12, string*66, date7, time7 C ---------------------------------------------------------------C --------------------------------------------------------------- C ... Do NOT use stmt. labels numbered less than 11! A bug in FCC ... Do NOT use stmt. labels numbered less than 11! A bug in FC C ---------------------------------------------------------------C --------------------------------------------------------------- 11 format( 3X, 1pe11.3)11 format( 3X, 1pe11.3) date7 = "trick 2":date7 = "trick 2": time7 = "pass it"time7 = "pass it" call getdate( date7, time7)call getdate( date7, time7) fn = "~4plots.plt":fn = "~4plots.plt": ifile = 30+iplotifile = 30+iplot C if more than one plot (iplot), change filetype as shown on next line.C if more than one plot (iplot), change filetype as shown on next line. if( iplot .gt. 1) write(fn, '("~4plots.", i1, "lt")') iplotif( iplot .gt. 1) write(fn, '("~4plots.", i1, "lt")') iplot !! print *, "ifile, fn = ", ifile, fnprint *, "ifile, fn = ", ifile, fn !! print *, " "print *, " " open( ifile, FILE=fn, Status='unknown')open( ifile, FILE=fn, Status='unknown') C 1st line is file name for this problem.C 1st line is file name for this problem. ! file name of file that created this output plot.! file name of file that created this output plot. write(ifile, *) "=== enter your file name that calculated these points ==="write(ifile, *) "=== enter your file name that calculated these points ===" write(ifile,11) errPoswrite(ifile,11) errPos ! 'errsum' value ... gives user idea of convergence.! 'errsum' value ... gives user idea of convergence. C change 'Bang Bang 2a, Fixed Time' in following 3 lines to your program name.C change 'Bang Bang 2a, Fixed Time' in following 3 lines to your program name. string = "=== enter problem title here === ... Sol'n: " // date7 //string = "=== enter problem title here === ... Sol'n: " // date7 // + " @ " // time7+ " @ " // time7 write(ifile, *) stringwrite(ifile, *) string C ModelX ... must be > 20 ... hmmm, not sure how to find this.C ModelX ... must be > 20 ... hmmm, not sure how to find this. modelx = 21modelx = 21 C nTerms is number of terms in series.C nTerms is number of terms in series. nterms = 0nterms = 0 C nPoints is number of points to be read and then plotted.C nPoints is number of points to be read and then plotted. nPoints = nptsnPoints = npts ! you need to calculate or enter value for 'npts' here! you need to calculate or enter value for 'npts' here C nCurves is number of curves in table ... 1 or 2?C nCurves is number of curves in table ... 1 or 2? nCurves = 1nCurves = 1 C nArrays is number of Arrays in series.C nArrays is number of Arrays in series. nArrays = 0nArrays = 0 write(ifile, *) modelx, nterms, nPoints, nCurves, nArrayswrite(ifile, *) modelx, nterms, nPoints, nCurves, nArrays write(ifile, *) " "write(ifile, *) " " ! filename if you want it, blank if not.! filename if you want it, blank if not. y0 = 0y0 = 0 ! x-offset value! x-offset value write(ifile, *) y0write(ifile, *) y0 write(ifile,*) "=== your plot title goes here ===" ! plot titlewrite(ifile,*) "=== your plot title goes here ===" ! plot title write(ifile,*) "Time (seconds)" ! x-axis titlewrite(ifile,*) "Time (seconds)" ! x-axis title write(ifile,*) "Velocity (mph)" ! y-axis titlewrite(ifile,*) "Velocity (mph)" ! y-axis title print *, ' 'print *, ' ' print *,' ================ End of Run ==========='print *,' ================ End of Run ===========' do 90 i=1, nPointsdo 90 i=1, nPoints x = time(i): y1= velocity(i):x = time(i): y1= velocity(i): y2 = 0y2 = 0 C set 'y2' to zero if not used as shown above OR remove y2 from next line.C set 'y2' to zero if not used as shown above OR remove y2 from next line. write(31, 11) x, y1, y2write(31, 11) x, y1, y2 90 continue90 continue close( 31)close( 31) endend subroutine getdate( date7, time7)subroutine getdate( date7, time7) character*(*) date7, time7character*(*) date7, time7 call date( date7)call date( date7) call time( time7)call time( time7) returnreturn endend See fc-compilertemplateXYplot-code.fc0 file for this plot code
  45. 45. Helpful TipsHelpful Tips Normalize your data ... between -1 & 1 or 0 & 1Normalize your data ... between -1 & 1 or 0 & 1 To start ... use '1' amplitude valuesTo start ... use '1' amplitude values Once model is looking good, round last results toOnce model is looking good, round last results to 2 or 3 digits and try again. Think about your2 or 3 digits and try again. Think about your solution terrain, any dead-ends?solution terrain, any dead-ends? Any parametersAny parameters dependent on others?dependent on others? If so, tryIf so, try JupiterJupiter solver ...solver ... usesuses HessianHessian matrix to converge on solution.matrix to converge on solution.
  46. 46. Sinusoidal Curve fit to dataSinusoidal Curve fit to data 'n' Sine functions each with 3 parameters'n' Sine functions each with 3 parameters A side note:
  47. 47. Some ParametersSome Parameters areare NOTNOT Independent!Independent! ffii andand thetathetaii are dependent parameters!are dependent parameters! They depend uponThey depend upon aaii So start search with 'large'So start search with 'large' aaii valuesvalues to insure partial(to insure partial(ffii, t) & partial(, t) & partial(thetathetaii, t) will carry some weight., t) will carry some weight. Try another Solver!Try another Solver! JUPITERJUPITER is a keyis a key solver for tuff problems.solver for tuff problems.
  48. 48. Quiz TimeQuiz Time A plane crashed!A plane crashed! 'n' sites have debris'n' sites have debris Find time-line of debris trail & other sightingsFind time-line of debris trail & other sightings
  49. 49. Plane Crash Time-linePlane Crash Time-line o o oo o o locPlane=???: velPlane= Err=0: g= 32.??? ...locPlane=???: velPlane= Err=0: g= 32.??? ... FindFind timetime, height, velocity, etc. ..., height, velocity, etc. ... To MinimizeTo Minimize ErrErr o o oo o o ErrH=0: dt= tf=ErrH=0: dt= tf= InitiateInitiate ISIS;ISIS; forfor abcModel;abcModel; equationsequations dydt / y,dydt / y, ... ;... ; ofof tt;; stepstep dt;dt; toto tftf do i = 1, nSitesdo i = 1, nSites tt==time(i)time(i): h=height(i): v=velocity(i) ...: h=height(i): v=velocity(i) ... do while (do while (hObjecthObject .ge. hDat(i)).ge. hDat(i)) IntegrateIntegrate abcModel;abcModel; byby ISISISIS ! print *,! print *, tt, dydt, y, h, dydt, y, h end doend do time(i)time(i) == tt : ErrH = ErrH + (locPlane + velPlane * t: - hDat(i))**2: ErrH = ErrH + (locPlane + velPlane * t: - hDat(i))**2 end doend do ErrErr = ErrH + ErrVel + ErrLoc + ...= ErrH + ErrVel + ErrLoc + ... ! Recommend normalizing your ErrXXX variables; Direction vs. Velocity Error Importance?! Recommend normalizing your ErrXXX variables; Direction vs. Velocity Error Importance? EndEnd Model abcModelModel abcModel hObjecthObject = h - g *= h - g * tt ** tt / 2/ 2 ! stop fall when h = height / elevation of debris! stop fall when h = height / elevation of debris EndEnd ! save time 't' for fall.! save time 't' for fall.
  50. 50. Variable FlowVariable Flow e.g. finding Planee.g. finding Plane DirectionDirection o o oo o o <dirPlane> = -999<dirPlane> = -999 ! '-999' flag for no data available! '-999' flag for no data available FindFind timetime,, ... To Minimize Err... To Minimize Err o o oo o o ErrDirErrDir=0=0 InitiateInitiate ISIS;ISIS; forfor abcModel; ...abcModel; ... do i = 1, nSitesdo i = 1, nSites o o oo o o if( dirObj(i) .eq. -999.) go to 22 ! no data available!if( dirObj(i) .eq. -999.) go to 22 ! no data available! dirPlane(i) = dirObj(i)dirPlane(i) = dirObj(i) ErrDirErrDir == ErrDirErrDir + ( dirPlane(i) - dirObj(i))**2+ ( dirPlane(i) - dirObj(i))**2 22 continue22 continue o o oo o o end doend do Err = ErrH + ErrVel + ErrLoc +Err = ErrH + ErrVel + ErrLoc + ErrDirErrDir ...... ! Recommend normalize!! Recommend normalize! EndEnd
  51. 51. Quiz: Variable FlowQuiz: Variable Flow e.g. finding Planee.g. finding Plane VelocityVelocity o o oo o o <velPlane> = -999<velPlane> = -999 ! '-999' flag for no data available! '-999' flag for no data available FindFind timetime,, ... To Minimize Err... To Minimize Err o o oo o o ErrVelErrVel=0=0 InitiateInitiate ISIS;ISIS; forfor abcModel; ...abcModel; ... ! your turn, what code goes here in order to find plane velocity?! your turn, what code goes here in order to find plane velocity? do i = 1, nSitesdo i = 1, nSites ! any additions in remainder of code for plane velocity?! any additions in remainder of code for plane velocity?
  52. 52. Crash Conclusion ProceduresCrash Conclusion Procedures Now you should have a plane time-line of events. Plot planeNow you should have a plane time-line of events. Plot plane height, velocity, direction, etc. over time-line in order to analysisheight, velocity, direction, etc. over time-line in order to analysis flight.flight. With the 2 last event points, calculate their slope. Is the planeWith the 2 last event points, calculate their slope. Is the plane heading for a crash? If so, when ... how long (time & distance)heading for a crash? If so, when ... how long (time & distance) before crash?before crash? Try to extrapolate, from the last few data points, where theTry to extrapolate, from the last few data points, where the plane may have crashed.plane may have crashed.
  53. 53. What are you building?What are you building? Mr. Arithmetic Mr. Algebra Mr. CalculusMr. Arithmetic Mr. Algebra Mr. Calculus ------------------- --------------- ----------------------------------- --------------- ---------------- Slide Rule Simulation OptimizeSlide Rule Simulation Optimize Optimal Designs EnterpriseOptimal Designs Enterprise goal-driven.netgoal-driven.net
  54. 54. ConclusionConclusion UseUse FortranCalculusFortranCalculus to improveto improve Math ModelsMath Models Design ProductivityDesign Productivity Manufacturing TolerancesManufacturing Tolerances
  55. 55. Comments & FeedbackComments & Feedback Have a new Curve Fit Model?Have a new Curve Fit Model? Have data set for Human Heart Beat, 1-cycle?Have data set for Human Heart Beat, 1-cycle? If so, please contact us atIf so, please contact us at optim.designs@gmail.comoptim.designs@gmail.com Once model is looking good, round last results toOnce model is looking good, round last results to 2 or 3 digits and try again.2 or 3 digits and try again.

×