Samir Khan

1169 Reputation

14 Badges

11 years, 237 days

My role is to help customers better exploit our tools. I’ve worked in selling, supporting and marketing maths and simulation software for all my professional career.

I’m fascinated by the full breadth and range of application of Maple. From financial mathematics and engineering to probability and calculus, I’m always impressed by what our users do with our tools.

However much I strenuously deny it, I’m a geek at heart. My first encounter with Maple was as an undergraduate when I used it to symbolically solve the differential equations that described the heat transfer in a series of stirred tanks. My colleagues brute-forced the problem with a numerical solution in Fortran (but they got the marks because that was the point of the course). I’ve since dramatized the process in a worksheet, and never fail to bore people with the story behind it.

I was born, raised and spent my formative years in England’s second city, Birmingham. I graduated with a degree in Chemical Engineering from The University of Nottingham, and after completing a PhD in Fluid Dynamics at Herriot-Watt University in Edinburgh, I started working for Adept Scientific – Maplesoft’s partner in the UK.

MaplePrimes Activity

These are Posts that have been published by Samir Khan

This is a post that I wrote for the Altair Innovation Intelligence blog.

I have a grudging respect for Victorian engineers. Isambard Kingdom Brunel, for example, designed bridges, steam ships and railway stations with nothing but intellectual flair, hand-calculations and painstakingly crafted schematics. His notebooks are digitally preserved, and make for fascinating reading for anyone with an interest in the history of engineering.

His notebooks have several characteristics.

  • Equations are written in natural math notation
  • Text and diagrams are freely mixed with calculations
  • Calculation flow is clear and well-structured

Hand calculations mix equations, text and diagrams.


Engineers still use paper for quick calculations and analyses, but how would Brunel have calculated the shape of the Clifton Suspension Bridge or the dimensions of its chain links if he worked today?

If computational support is needed, engineers often choose spreadsheets. They’re ubiquitous, and the barrier to entry is low. It’s just too easy to fire-up a spreadsheet and do a few simple design calculations.

 Spreadsheets are difficult to debug, validate and extend.


Spreadsheets are great at manipulating tabular data. I use them for tracking expenses and budgeting.

However, the very design of spreadsheets encourages the propagation of errors in equation-oriented engineering calculations

  • Results are difficult to validate because equations are hidden and written in programming notation
  • You’re often jumping about from one cell to another in a different part of the worksheet, with no clear visual roadmap to signpost the flow of a calculation

For these limitations alone, I doubt if Brunel would have used a spreadsheet.

Technology has now evolved to the point where an engineer can reproduce the design metaphor of Brunel’s paper notebooks in software – a freeform mix of calculations, text, drawings and equations in an electronic notebook. A number of these tools are available (including Maple, available via the APA website).

 Modern calculation tools reproduce the design metaphor of hand calculations.


Additionally, these modern software tools can do math that is improbably difficult to do by hand (for example, FFTs, matrix computation and optimization) and connect to CAD packages.

For example, Brunel could have designed the chain links on the Clifton Suspension Bridge, and updated the dimensions of a CAD diagram, while still maintaining the readability of hand calculations, all from the same electronic notebook.

That seems like a smarter choice.

Would I go back to the physical notebooks that Brunel diligently filled with hand calculations? Given the scrawl that I call my handwriting, probably not.

Some time ago, @marc005 asked how he could send an email from the Maple command line.

Why would you want to do this? Using Maple's functionality, you could programatically construct an email - perhaps with the results of a computation - and email it yourself or someone else.

I originally posted a solution that involved communicating with a locally-installed SMTP server using the Sockets package. But of course, you need to set up an SMTP server and ensure the appropriate ports are open.

I recently found a better solution. Mailgun ( is a free email delivery service with an web-based API. You can communicate with this API via the URL package; simply send Mailgun a URL:-Post() message that contains account-specific information, and the text of your email.

The general steps and Maple commands are given below, and you can download the worksheet here.

Note: Maplesoft have no affiliation with Mailgun.

Step 1:
Sign up for a free Mailgun account.

Step 2:
In your Mailgun account, go to the Domains section - it should look like the screengrab below (account-specific information has been blanked).

Note down the API Base URL and the API key.

  • the API Base URL looks like  

Step 3:

In Maple, define strings containing your own API Base URL and API Key. Also, define the recipient's email address, the email you want the recipient to reply to, the email subject and email body.

>APIBaseURL := "":
>toEmail := "":
>fromEmail:="First Last <>":
>subject:= "Email Subject Goes Here":
>emailBody := "I'd rather have a bottle in front of me than a frontal lobotomy":

Step 4:
Run the following code

> URL:-Post(cat(APIBaseURL,"/messages"),[
"text"= emailBody],

If you've successfully sent the email, you should see something like this (account-specific information is blanked out)

You can also send HTML emails by replacing the "text" line with "html" = str, where str is a string with your HTML code.

CoolProp is an open source C++ library of thermophysical properties for pure fluids, pseudo-pure fluids, and humid air. Ian Bell has recently developed a wrapper for Maple (get the wrapper and library at Github). Compiling CoolProp gives a library (a DLL on Windows) you can call in Maple via define_external().

I started exploring CoolProp a few days ago, and here's a few simple examples of what you can do

The saturation pressure (in kPa) of the refrigerant R134a at 253 K

The pressure (in kPa) of the refrigerant R22 that produces a two-phase mixture of quality 0.3 with an enthalpy of 300 kJ/kg

And since I'm a fan of engineering visualization, here's a refrigeration cycle on a P-h-T chart, generated in Maple with CoolProp.

Here's a Maple application that uses CoolProp to analyze a refrigeration cycle (together with a CoolProp DLL for 64-bit Windows).

I'd like to encourage anyone with an interest in thermophysical modeling to download CoolProp and explore its functionality. It's certainly opened up a new field of applications for me.


1 Introduction

Three tanks are connected with two pipes. Each tank is initially filled to a different level. A valve in each pipe opens, and the liquid levels gradually reach equilibrium. Here, we model the system in MapleSim (including the influence of flow inertia), and also derive and solve the analytical equations in Maple.

Liquid flowing in a pipeline has inertia.  If a valve at the end of the pipeline suddenly closes, a pressure surge hits the valve, and travels through the pipeline at the speed of sound. The damping effect of fluid friction gradually attenuates the pressure wave.

This phenomenon is called water hammer and can cause damage significant damage, sometimes even rupturing the pipeline.

The pressure wave often produces audible sound. If you’ve ever heard...

2 3 4 5 6 7 8 Page 4 of 10