Maplesoft Blogger Profile: Samir Khan

Technical professional in industry or government

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.

Posts by Samir Khan

When Maple 2016 hit the road, I finally relegated my printed Mollier charts and steam tables to a filing cabinet, and moved my carefully-curated spreadsheets of refrigerant properties to a distant part of my hard drive. The new thermophysical data engine rendered those obsolete.

Other than making my desk tidier, what I find exciting is that I can compute with fluid properties in a tool that has numerical integrators, ODE solvers, optimizers, programmatic visualisation and more.

Here are several small examples that demonstrate how you can use fluid properties with Maple’s math and visualization tools (this worksheet contains the complete examples).

Work Done in Compressing a Gas

The work done (per unit mass) in compressing a fluid at constant temperature is

where V1 and V2 are specific volumes and p is pressure.

You need a relationship between pressure and specific volume (either theoretical or experimental) to calculate the work done.

Assuming the ideal gas law, the work done becomes

where R is the ideal gas constant, T is the temperature (in K) and M is the molecular mass (in kg mol-1), and V is the volume.

 Ideal gas constant

Molecular mass of propane

Hence the work done predicted by the Ideal Gas Law is

Let’s now use real fluid properties instead and numerical integrators to compute the work done.

Here, the work done predicted with the Ideal Gas Law and real fluid properties is similar. This isn’t, however, always the case for all gases (try experimenting with ammonia – its strong intermolecular forces result in non-ideal behavior).

Minimum Specific Heat Capacity of Water

The specific heat capacity of water varies with temperature like so.

Let's find the temperature at which the specific heat capacity of water is the lowest.

The lowest specific heat capacity occurs at 309.4 K; this is the temperature at which water requires the least energy to raise or lower its temperature.

Incidentally, this isn’t that far from the standard human body temperature of 310.1 K (given that the human body is largely water, one might hazard a guess why we have evolved to maintain this temperature).

Temperature-Entropy Plot for Water

Maple 2016 generates pressure-enthalpy-temperature charts and psychrometric charts out of the box. However, you can create your own customized thermodynamic visualizations.

This, for example, is a temperature-entropy chart for water, together with the two-phase vapor dome (the worksheet contains the code to generate this plot).

I'm also working on a lumped-parameter heat exchanger model with fluid properties (and hence heat transfer coefficients) that change with temperature. That'll be more complex than these simple examples, and will use Maple's numeric ODE solver.

You, I, and others like us, are the beneficiaries of decades of software evolution.

From its genesis as a research project at the University of Waterloo in the early 80s, Maple has continually evolved to meet the challenges of technical computing.

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.

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...

Pendulum Waves...

June 06 2011 Samir Khan 599 MapleSim

I recently stumbled upon a hypnotic video of 15 out-of-phase pendulums from a physics experiment at Harvard University.


A prospective customer recently asked if we had a MapleSim model of a double pipe heat exchanger. Heat exchangers are a critical unit operation in the process industries, and accurate models are needed for process control studies.  I couldn't find an appropriate model so I decided to derive the dynamic equations, and implement them using MapleSim's custom component interface.  I'll outline my modeling strategy in this blog post.

I lived in the UK before making the barely-considered decision to move to Canada.  I still have savings denominated in pounds sterling (all dutifully declared on my Canadian tax return).  Accordingly, I keep a close watch on the GBP-CAD exchange rate so I have some sense of my net worth.

When I arrived in Canada in July 2008, one pound sterling bought $2, down from $2.30 two years before that.  Today, the pound has devalued further and is worth around...

I spend much of my time traveling for business. These trips often last a week, and we try to visit as many potential customers as possible, and in the most efficient order. This involves matching our hosts' calendars with our own, booking the most cost effective travel options, and coping with last-minute cancellations and changes. It isn’t easy!

This has become so much easier with the advent of shareable calendars and mapping services, like Google Maps. ...

Sometimes the obvious escapes me, and it’s only due to some chance observation that I realize the same fundamental principles are everywhere.

A short time ago, I created a simple hydraulic network in MapleSim, and after experimenting with some of the parameters, found it gave the same behaviour as an electric circuit I’d modeled earlier.

Getting Things Done...

January 20 2010 Samir Khan 599

Around the time that Windows 98 was at its most popular, I used to dabble in programming Windows user interfaces with Visual C++ and the help of several thick MFC (Microsoft Foundation Class) manuals.  I wanted to create packaged (and admittedly simple) engineering applications. But for a chemical engineer with little background in Windows programming, combining math functionality with a user interface was time-consuming and cumbersome. (MFC can be arcane unless you’ve invested considerable time in learning the API.)

Later, I migrated to VB6.  Designing an interface was an order of magnitude easier, but I still had to roll many of my own math routines, or link to external libraries. While I may be interested in the mathematical mechanics of adaptive step sizing in Runge-Kutta algorithms at the intellectual level, it was secondary to my then goal.

The Diet Problem...

December 17 2009 Samir Khan 599

If you were to stroll into the Application Engineering office at Maplesoft, you might be led to believe that we subsist on nothing but donuts, pizza, chocolate and coffee.  It’s even worse at this time of year when we have many more opportunities to over-consume. I try to have a balanced diet, but there are too many temptations scattered around the office (including candy at the office entrance – our receptionist, Walli, expects me at 3pm each day without fail). It doesn’t help that a virtually limitless supply of donuts are only a three minute drive away.

Resellers buy products from a manufacturer, and sell to consumers.  They are an important factor in many industries, including the one in which I work.  Maplesoft operates through a network of resellers throughout the world (apart from North America and a few other territories).  Some may suspect I’m somewhat biased in promoting the importance of resellers; I spent seven years working for Adept Scientific, Maplesoft’s partner in the UK.

The largest resellers are based in larger, better developed markets with a strong manufacturing and research base (like Cybernet and Scientific Computers in Japan and Germany).  Conversely, many smaller resellers, like Multi-On and Czech Software First in Mexico and the Czech Republic, operate in markets with significant growth potential.

Dual- and quad-core PCs are now ubiquitous.  While making your operating system a better multi-tasking environment, they’ve had a limited effect on the code that most technical professionals write.  This is largely because of the perceived difficulty of parallel programming.   The evolution , however, of high-level languages that support multi-threading throughout the 90s and beyond, removed the need to manage threads at the low level, allowing engineers to concentrate on what part of the algorithm could be run in parallel.  Given the ever-increasing complexity of systems that have to be simulated, multi-threaded programming can offer significant time savings for many the problems that can be easily parallelized (and for which time-savings of parallelization outweigh the overhead).

Training Day...

November 05 2009 Samir Khan 599

The first professional training course I gave involved a 275 mile late evening drive in a 1 litre European econobox from Letchworth in the UK to a dingy hotel in Alnwick.  I was pretty nervous –some of my delegates were engineers who had been using Mathcad for over ten years, and I was being paid to tell them what they didn’t know.  The following day, after drinking several litres of coffee, I drove another five miles to the training location, only to find that just one delegate had turned up.  Luckily he was just an intern who’d never used Mathcad before – and to him I was an expert.

1 2 Page 1 of 2