Samir Khan

1744 Reputation

19 Badges

14 years, 158 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

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



Not in the same league as the "Mandelbulb" pictures you may be referrng to, but a couple of years ago I messed around with plotting 3D Quaternions in Maple. Pictures in the attached worksheet


4 5 6 7 8 9 10 Page 6 of 11