Lessons Learned from Application Development with the Wolfram Language

Andrew Yule, Assured Flow Solutions LLC

Join the Conversation #WolframTechConf

Outline

Assured Flow Solutions - Company overview

Technology In the Oil and Gas Industry

Assured Flow Solutions’s Alex

Application Development with the Wolfram Language

Wolfram Language vs. Traditional Languages

Conclusion

Assured Flow Solutions - Company overview

About me

Chemical engineer

5 years of industry experience

Passion for Wolfram Language

Company overview

Specialty engineering/consulting company focusing on upstream oil and gas

Show[,ImageSize->600]

Flow assurance??

Attempt to “assure” flow of hydrocarbons from reservoir to topsides

ImageCollage[{,,,,},ImagePadding->15,Background->White,Method->"Rows",ImageSize->750]

Locations

Four locations (2x Houston, 1x Dallas, 1x Denver)

Show[,ImageSize->500]

New production chemistry lab

Opened last January

Focused on providing third party chemical verification and independent fluid analysis

Couples tightly with the engineering/consulting work

ImageCollage[{1,1,1}->{,,},ImagePadding->10,Background->White,ImageSize->700]

Technology in the Oil and Gas Industry

Technology focus

Technology in oil and gas industry = Better drilling

Better drilling = HUGE financial gains

Generally late to the game on computer technology

Excel still dominant

Technology at AFS

Current

Expensive simulation software, Excel, one-off executables

Personally use Wolfram Language for 80% of my daily work

Need at AFS to better manage our own internal processes, workflows, and calculations

Collective effort to create something to handle this

What we needed

Something that could encompass our entire tool set

Show[,ImageSize->1000]

Assured Flow Solutions’s Alex

The Library of Alexandria

One of the largest and most significant libraries of the ancient world

Hoping not to have the same ending...

Show[,ImageSize->600]

Assured Flow Solutions’s Alex

Developed in Mathematica and distributed via Enterprise CDF

Currently contains 37 unique utilities

Utilities are combinations of calculations and workflows

SystemOpen["C:\\Users\\ayule\\Desktop\\AFS - Alex.lnk"];

SlideView[ImageCollage[#,ImagePadding->15,Background->White,ImageSize->1150]&/@ArrayReshape[Import/@SortBy[FileNames[__,"C:\\Users\\ayule\\Google Drive\\Wolfram Technical Conferences\\2016\\Full Alex Screenshots"],FileDate[#]&],{4,6}]]

Leverage power of enterprise CDF by allowing for arbitrary inputfields and importing of any file type

Searchable makes it easy to find the right utility for the job

Added support for over 250 oil and gas units with easy conversion

ConvertUnit[50,"C","F"]

Quick example 1

Alex`HydrateCurves`InitializeVars[];
Alex`HydrateCurves`UI

Quick example 2

Show[,ImageSize->500]

Alex`CalcBasedCooldownCalculator`InitializeVars[];
Alex`CalcBasedCooldownCalculator`UI

Application Development with the Wolfram Language

How to develop Alex?

Style[Grid[{
{Item["",ItemSize->10],Item[,Alignment->{Center},ItemSize->15],Item[,Alignment->Center,ItemSize->15],Item[,Alignment->Center,ItemSize->15]},
{Item[Style["Pros",20],Alignment->Center],Column[{"• Available to everyone"}],Column[{"• Complete control over functionality, installation, and distribution"}],Column[{"• VERY fast development","• Access to over 5,000 functions"}]},
{Item[Style["Cons",20],Alignment->Center],Column[{"• VERY slow development","• Poor support for extensions"}],Column[{"• Slow development","• Limited by open source libraries (specifically for math functions)"}],Column[{"• Limits with distribution/installation"}]}
},Alignment->{Left,Center},Frame->All,Spacings->{2, 2}],15,Bold,FontFamily->"Segoe UI",Background->Lighter[Gray, 0.5]]

Application Development with the Wolfram Language

Code structure

Alex is contained in a package

Really nice for naming conventions and code isolation

Use package editor for ability to collapse sections

CDF is separate, but works as a “viewer” into the package contents

Show[,ImageSize->700]

By separating Alex from the CDF, it’s possible to encode and protect the intellectual property

Application Development with the Wolfram Language

Insights into the UI

Mathematica not meant to create the typical UI we are used to seeing

However, still possible to create nice looking UI’s using available constructs

SlideView[Show[#,ImageSize->850]&/@Import["C:\\Users\\ayule\\Google Drive\\Wolfram Technical Conferences\\2016\\UI Design\\Images.xlsx","Images"]]

Application Development with the Wolfram Language

“Compiling” Alex

Build function, copies over Encoded *.wl files to correct directories

$UserBaseDirectory

Accepts an option for new version number

Alex`CompileAlex[]

Alex`CompileAlex["VersionNumber"->"1.1.13.0"]

Application Development with the Wolfram Language

Version control

Version control is crucial for any successful software project

Alex.wl is maintained using GIT for version control

Easy because Wolfram Language is normal text

Also nice for spotting differences between versions

Application Development with the Wolfram Language

Updates

Updates are constantly being made

EXE created to copy files to correct CDF folders

$UserBaseDirectory

Creates a shortcut on the desktop

Show[]

Application Development with the Wolfram Language

Automated testing

Very easy using Wolfram’s testing capabilities

Many utilities include core calculation functions making it easy to test

ImageCollage[{,},ImagePadding->15,Background->White,ImageSize->Full]

Application Development with the Wolfram Language

Bug reporting

Automatic emailing

Show[,ImageSize->Full]

SendMail["..."]

Application Development with the Wolfram Language

Debugging

Separate utilities and naming conventions makes debugging significantly easier

Alex`HydrateCurves`UI

Alex`HydrateCurves`addInhibitor

Alex`HydrateCurves`hydrateCurves

Application Development with the Wolfram Language

Extras

Copy to clipboard

CopyToClipboard[{{1,2,3},{4,5,6}}]

CopyDataToClipboard[{{1,2,3},{4,5,6}}]

Save/Load

(*****SAVE Method*****)
(*Create the file contents as an association for each variable by name*)
mFileContents = Association[ReplaceAll[Names["Alex`IronProduction`g*"],x_String:>(x->Symbol[x])]];
(*Save the contents*)   Put[mFileContents, mFile];

Show[,ImageSize->500]

(*****LOAD Method*****)
(*Get the contents of the file*)
mFileContents = Get[mFile];
(*Load all variables in the file based on the key name which is equal to the variable name*)
(Clear[#];Evaluate[Symbol[#]]=mFileContents[#];)&/@Normal[mFileContents][[All,1]];

Wolfram Language vs. Traditional Languages

Advantages of Wolfram Language for application development

Algorithms can be developed VERY quickly

Generally requires less code

Limitations of Wolfram Language for application development

Strongest limitations show in the UI capabilities

Notebooks cannot always translate to a desktop style application

Not meant for professional desktop class application

Perfect for quick and efficient internal development

Conclusion

Future of Alex

Growing list of utilities to add

Current items deal mostly with engineering work, possibility to grow into the lab side of things

Cloud opportunities

Wolfram Language will continue to play a vital role at AFS

Wolfram Language can play a huge role in every industry

Must continue to increase awareness