Samir Khan

1839 Reputation

19 Badges

15 years, 147 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 answers submitted by Samir Khan

@arctica 

Here's a quick and dirty translation of 5.2.pdf to Maple.  

Mathcad_5.2.mw

I haven't done any detailed checking or used units - this was just a first pass conversion

The heat loss Q would be proportional to delta T.  It wouldn't be constant.

The box will lose heat by conduction to the outside world

A better model may be to connect the following blocks together.

Fixed Temperature - Thermal Conductor - Heat Capacitor

Samir

1) Assuming that the data from the procedure is assinged to str, then the following hacky code lifted from the Stock Import worksheet works (which was incidently written at 3am in the morning during a thunderstorm - hence the hackiness)

strLength := StringTools[Length](str):
start := StringTools[Search]("Adj Close", str)+10:
str2 := StringTools[SubString](str, start .. strLength):
newlines := StringTools[SearchAll]("\n", str2):
days := nops([newlines]):
commas := StringTools[SearchAll](",", str2):
pos := sort([1, commas, newlines, StringTools[Length](str2)]):
data := Matrix(days, 7):
k := 1:
for i to days do
   for j to 7 do
      if k < nops(pos) then
         str3 := StringTools[SubString](str2, pos[k] .. pos[k+1]):
         strAscii := convert(str3, bytes):
         strAscii := remove(has, strAscii, 10):
         strAscii := remove(has, strAscii, 44):
         strAscii := remove(has, strAscii, 13):
         strAscii := remove(has, strAscii, 34):
         strClean := convert(strAscii, bytes):
         if j <> 1 then
            data[i, j] := parse(strClean)
         else
            data[i, j] := strClean
         end if;
      k := k+1
      end if
   end do
end do:
data;

Samir

 

Ivar,

One way of doing this is in a Maple document attached to a MapleSim model.

 * Let say that you have a MapleSim model that returns 4 plots

* Attach say the Equations template to the MapleSim model

*Scroll to the bottom and execute the following commands

> with(DocumentTools); with(MapleSim); with(plots);
> theModel := GetProperty(Simulation0, system);
 

the following command returns an array; the first column is time, and the remaing columns are all probe values.
> data := RunSimulation(theModel, output = datapoint, returnTimeData);

Hence to plot the first probe value against time for the whole range (assuming 200 points in total)
> plotdata := [seq([data[i, 1], data[i, 2]], i = 1 .. 200)];
> pointplot(plotdata);
 

To plot all the probes over a specific time range
> plotdata := seq(pointplot([seq([data[i, 1], data[i, j]], i = 150 .. 175)], connect = true), j = 2 .. 5);
> display(Array([plotdata]));
 

Please see the attached MapleSim model for a worked example, and let us know if you have any questions.

Download 8983_ivar.zip
View file details

Add method=branchandbound to the GlobalSolve command, i.e.

GlobalSolve(add(Difference[p]^2,p=1..6), op(VarRanges), method=branchandbound);

It's now insensitive to your search range.  The default method is multistart.

Samir

1 2 3 4 Page 4 of 4