Sei sulla pagina 1di 34

CAPD&S

Tsegay G.

Programming
Basics
MATLAB Fundamentals

Computer Aided Process Design & Simulation Basics of MATLAB


Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?
Tsegay G.

Department of Chemical Engineering


tsegay.gebrekidan@mu.edu.et

November 20, 2018

Tsegay G. (EiT-M) CAPD&S November 20, 2018 1 / 29


CAPD&S
Outline
Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
1 Programming Basics For?
What is Aspen Plus

MATLAB Fundamentals process simulation model?

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand For?
What is Aspen Plus process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 2 / 29


CAPD&S
MATLAB Fundamentals
Tsegay G.

Introduction Programming
Basics
What is MATLAB? MATLAB Fundamentals

Basics of MATLAB
MATLAB stands for MATrix LABoratory Matrices and Vectors
Introducing Aspen Plus
MATLAB is a high-level technical computing language What Does Aspen Stand
For?

and interactive environment for algorithm development, What is Aspen Plus


process simulation model?

data visualization, data analysis, and numerical


computation.
Using MATLAB, you can solve problems faster than
programming languages, such as C, C ++ , and
FORTRAN.
MATLAB is widely used for teaching and research in
universities and industry.
It contains hundreds of commands to do mathematics.
It is a high-level programming language that can
communicate with its cousins, e.g., FORTRAN and C.
Tsegay G. (EiT-M) CAPD&S November 20, 2018 3 / 29
CAPD&S
Why do users prefer MATLAB?
Tsegay G.

Programming
MATLAB enables you to perform computationally intensive Basics

tasks faster than with traditional programming languages MATLAB Fundamentals

such as C, C ++ , and FORTRAN.


Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
With MATLAB, although there is a GUI, you will need to What is Aspen Plus
process simulation model?
understand mathematics and programming concepts and be
able to write code in order to get the most out of the
software.

With over one million users, MATLAB is recognized as a


standard tool for increasing the productivity of engineers and
scientists.

Employers worldwide consistently report the advantages of


being MATLAB proficient.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 4 / 29


CAPD&S
Cont’
Tsegay G.

Programming
MATLAB has several advantages over other methods or Basics
languages: MATLAB Fundamentals

Basics of MATLAB
It is user - friendly. Matrices and Vectors
Introducing Aspen Plus

Tasks can be accomplished with a single function call. What Does Aspen Stand
For?
What is Aspen Plus
It contains large number of built-in functions. process simulation model?

MATLAB treats all variables as matrices, scalar - 1 x 1


matrix, vector - 1 x N or N x 1 matrix. This makes
calculations a lot faster.
All numerical objects are treated as double-precision
arrays. Thus there is no need to declare data types and
carry out type conversions.
There is extensive graphics support that allows the
results of computations to be plotted with a few
statements.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 5 / 29


CAPD&S
Cont’
Tsegay G.

There are also disadvantages: Programming


Basics
It uses a large amount of memory and slow computers. MATLAB Fundamentals

It prevent users from understanding the basic principles Basics of MATLAB

of programming since it does not require in-depth Matrices and Vectors


Introducing Aspen Plus

knowledge on operational principle of programming like What Does Aspen Stand


For?

compiling and linking. What is Aspen Plus


process simulation model?

It sits "on top" of Windows, getting as much CPU time


as Windows allows it to have. This makes real-time
applications very complicated.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 6 / 29


CAPD&S
Cont’
Tsegay G.

There are also disadvantages: Programming


Basics
It uses a large amount of memory and slow computers. MATLAB Fundamentals

It prevent users from understanding the basic principles Basics of MATLAB

of programming since it does not require in-depth Matrices and Vectors


Introducing Aspen Plus

knowledge on operational principle of programming like What Does Aspen Stand


For?

compiling and linking. What is Aspen Plus


process simulation model?

It sits "on top" of Windows, getting as much CPU time


as Windows allows it to have. This makes real-time
applications very complicated.
Starting MATLAB and MATLAB Windows
You can start MATLAB by either of the following.
Start − > Programs − > MATLAB − > MATLAB, or
Double−click the MATLAB shortcut icon on your
Window desktop.
When you start MATLAB, the desktop appears in its default
layout.
Tsegay G. (EiT-M) CAPD&S November 20, 2018 6 / 29
CAPD&S
Cont’
Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 7 / 29


The desktop includes these panels: CAPD&S

Tsegay G.
Current Directory Browser
Programming
The directory (folder) that MATLAB is currently Basics
MATLAB Fundamentals
working in.
Basics of MATLAB

This is where anything you save will go by default, Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
You won’t be able to run a script that you saved that For?
What is Aspen Plus
you saved in a different directory (unless you give the process simulation model?

full directory path), but you can run one that’s in a


sub-directory.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 8 / 29


The desktop includes these panels: CAPD&S

Tsegay G.
Current Directory Browser
Programming
The directory (folder) that MATLAB is currently Basics
MATLAB Fundamentals
working in.
Basics of MATLAB

This is where anything you save will go by default, Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
You won’t be able to run a script that you saved that For?
What is Aspen Plus
you saved in a different directory (unless you give the process simulation model?

full directory path), but you can run one that’s in a


sub-directory.

Command Window
used to enter commands at the command line, indicated
by the prompt (>>)
used to run a program you have written for MATLAB
helpful to use MATLAB as a calculator and a graphing
tool

Tsegay G. (EiT-M) CAPD&S November 20, 2018 8 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Workspace Browser Basics
MATLAB Fundamentals
It is empty at startup
Basics of MATLAB

Shows the properties of currently defined variables Matrices and Vectors


Introducing Aspen Plus
What Does Aspen Stand
The name of each variable, its array size, and its size in For?
What is Aspen Plus
bytes are listed process simulation model?

A function alternative for this panel is to type whos in


the Command Window
Variables can be deleted with the clear command

Tsegay G. (EiT-M) CAPD&S November 20, 2018 9 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Workspace Browser Basics
MATLAB Fundamentals
It is empty at startup
Basics of MATLAB

Shows the properties of currently defined variables Matrices and Vectors


Introducing Aspen Plus
What Does Aspen Stand
The name of each variable, its array size, and its size in For?
What is Aspen Plus
bytes are listed process simulation model?

A function alternative for this panel is to type whos in


the Command Window
Variables can be deleted with the clear command

Command History Window


It is used to view or rerun commands that you entered
at the command line by up arrow key or double click.

The help browser and edit window are open by using menu
selection on the command window.
Tsegay G. (EiT-M) CAPD&S November 20, 2018 9 / 29
The Help Browser CAPD&S

Tsegay G.
Use the Help browser to search and view documentation
and demonstrations for MATLAB and all other installed Programming
Basics
Math Works products. MATLAB Fundamentals

Click on the Help tab on the top tool bar or click on the Basics of MATLAB
Matrices and Vectors

help browser icon in the main MATLAB window. Introducing Aspen Plus
What Does Aspen Stand
For?
The tabs in the Help Window Navigator (shown below) What is Aspen Plus
process simulation model?
provide different ways to search for information:
contents, index, or search.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 10 / 29


The Help Browser CAPD&S

Tsegay G.
Use the Help browser to search and view documentation
and demonstrations for MATLAB and all other installed Programming
Basics
Math Works products. MATLAB Fundamentals

Click on the Help tab on the top tool bar or click on the Basics of MATLAB
Matrices and Vectors

help browser icon in the main MATLAB window. Introducing Aspen Plus
What Does Aspen Stand
For?
The tabs in the Help Window Navigator (shown below) What is Aspen Plus
process simulation model?
provide different ways to search for information:
contents, index, or search.

Edit Window
Select File − > New − > M-file from the MATLAB
toolbar or click the new file icon to open editor window.
Used to create new and/or edit existing M-files.
A text editor for writing MATLAB programs.
Colors are used to highlight various parts of the
language (e.g. comments, variables, numbers, and
strings.
Tsegay G. (EiT-M) CAPD&S November 20, 2018 10 / 29
CAPD&S

Tsegay G.
Figure Windows
Programming
Used by MATLAB to display graphics: two- or Basics
MATLAB Fundamentals
three-dimensional plots, images, etc.
Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 11 / 29


CAPD&S

Tsegay G.
Figure Windows
Programming
Used by MATLAB to display graphics: two- or Basics
MATLAB Fundamentals
three-dimensional plots, images, etc.
Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 11 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 12 / 29


CAPD&S
Basics of MATLAB
Tsegay G.

Programming
Arithmetic operations Basics
MATLAB Fundamentals

MATLAB utilizes the following arithmetic operators: Basics of MATLAB

Operation MATLAB Code Matrices and Vectors


Introducing Aspen Plus

No For the operator What Does Aspen Stand


For?
What is Aspen Plus
1 Addition + process simulation model?

2 Subtraction -
3 Multiplication *
4 Element-wise multiplication .*
5 Division /
6 Element-wise division ./
7 Left division \
8 Left element- wise left division .\
9 Exponentiation ^
10 Element-wise Exponentiation .^

Tsegay G. (EiT-M) CAPD&S November 20, 2018 13 / 29


MATLAB prints the answer and assigns the value to a CAPD&S

variable called ans Tsegay G.

If you want to perform further calculations with the Programming


answer, you can use the variable ans rather than retype Basics
MATLAB Fundamentals
the answer. Basics of MATLAB

For example, you can compute the sum of the square of Matrices and Vectors
Introducing Aspen Plus

answer and six times answer as follows: What Does Aspen Stand
For?
What is Aspen Plus

 32 − (5 + 4)/2 + 6 ∗ 3 process simulation model?

ans =
22.5000
 ans 2 + 6 ∗ ans + 5
ans =
646.2500
Errors in Input
If you make an error in an input line, MATLAB will
normally print an error message. For example, here’s
what happens when you try to evaluate :
Tsegay G. (EiT-M) CAPD&S November 20, 2018 14 / 29
Built-in Functions CAPD&S

Tsegay G.
MATLAB has many built-in functions.
Common built-in functions are given in the table below. Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 15 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Basics
MATLAB Fundamentals
MATLAB also has several built-in constants, including Basics of MATLAB

pi (the number Π), i (the complex number ), and Inf Matrices and Vectors
Introducing Aspen Plus

(inf) and NAN( Not a Number). What Does Aspen Stand


For?
What is Aspen Plus
In MATLAB, different characters are used to control process simulation model?

operations. Some of these are given below.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 16 / 29


CAPD&S
Changing the data format
Tsegay G.
MATLAB uses double-precision floating-point
Programming
arithmetic, which is accurate to approximately 15 digits; Basics
however, MATLAB displays only 5 digits by default. MATLAB Fundamentals

Basics of MATLAB
To display different digits or formats we use the Matrices and Vectors
Introducing Aspen Plus
following format commands: What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?
 ans = 12.345678901234567;

format short → 12.3457


format long → 12.34567890123457
format short e → 1.2346e+001
format long e → 1.234567890123457e+001
format short g → 12.346
format rat → 1000/81
format compact and format loose specify whether a
blank line appears between the input and output

Tsegay G. (EiT-M) CAPD&S November 20, 2018 17 / 29


CAPD&S
Matrices and Vectors
Tsegay G.

Programming
Basics
MATLAB Fundamentals

To enter a matrix in MATLAB, use square brackets. Basics of MATLAB


Matrices and Vectors

Separate entries within a row by spaces and separate Introducing Aspen Plus
What Does Aspen Stand
For?
rows using semicolons. What is Aspen Plus
process simulation model?

Often we do not want MATLAB to display a response


especially dealing with very large matrices. To suppress
the output, place a semicolon at the end of the line.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 18 / 29


CAPD&S
Cont’
Tsegay G.

For example Programming


Basics
defines the variable B MATLAB Fundamentals

containing a 2x3 matrix, but MATLAB will not echo Basics of MATLAB
Matrices and Vectors

anything Introducing Aspen Plus


What Does Aspen Stand

To view the content of the variable B, just type its For?


What is Aspen Plus
process simulation model?
name and press ENTER.

Vector is simply a matrix with a single row or column.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 19 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Basics
In MATLAB, there are two basic ways to define such vectors MATLAB Fundamentals

Basics of MATLAB
1 Using colon (:) Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
The syntax is x =xstart: increment: xend What is Aspen Plus
process simulation model?

2 Using the function linspace


The syntax is
x= linspace(xstart, xend, number of entries)

Tsegay G. (EiT-M) CAPD&S November 20, 2018 20 / 29


CAPD&S
Basic matrix and vector operations
Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 21 / 29


CAPD&S
Basic matrix and vector functions
Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?
What is Aspen Plus
process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 22 / 29


CAPD&S
Introducing Aspen Plus
Tsegay G.

What Does Aspen Stand For? Programming


Basics
ASPEN is an acronym of Advanced System for MATLAB Fundamentals

Process ENgineering. Basics of MATLAB


Matrices and Vectors
Introducing Aspen Plus
It is based on a flowsheet simulation. What Does Aspen Stand
For?

A flowsheet simulation is a computer software that is What is Aspen Plus


process simulation model?

used to quantitatively model a chemical processing


plant, which, in addition to the core reactor unit, also
includes pre-and post-treatment steps.
Thus, simulation of an entire chemical process, starting
from the raw material to the final finished product, is
symbolically represented by different icons
In terms of Aspen Plus flowsheet notation, there will be
a block icon and stream icon.
The iconic flowsheet simulator, such as Aspen Plus,
allows us to predict the behavior of a process using
basicG. engineering
Tsegay (EiT-M) relationships.
CAPD&S November 20, 2018 23 / 29
CAPD&S
Cont’
Tsegay G.

Programming
Basics
MATLAB Fundamentals

In general, writing such equations stems from Basics of MATLAB


Matrices and Vectors

balance equations of extensive thermodynamic Introducing Aspen Plus


What Does Aspen Stand
properties, such as mass, mole, and energy; For?
What is Aspen Plus
process simulation model?
thermodynamic relationships for reacting and
non-reacting medium, such as phase and chemical
equilibrium;
rate correlations for momentum, heat, and mass
transfer;
reaction stoichiometry and kinetic data;
physical constraints imposed on the process.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 24 / 29


CAPD&S
Cont’
Tsegay G.

Programming
Given reliable thermodynamic data, sensible operating Basics
conditions, and rigorous equipment models, Aspen Plus can MATLAB Fundamentals

simulate actual plant behavior. Basics of MATLAB


Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand

Aspen Plus flowsheet simulation enables us to run many For?


What is Aspen Plus
process simulation model?
tasks, such as
conduct "what if" tests;
design specification (plant configuration) checks;
carry out "de-bottle necking of constricting parts of a
process" studies;
perform sensitivity analyses;
run optimization investigations.
With Aspen Plus process simulator, we can design better
plants and increase profitability in existing plants.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 25 / 29


CAPD&S
What is Aspen Plus process simulation model?
Tsegay G.

In general, a chemical process consists of chemical Programming


components, or different species, that are subject to physical Basics
MATLAB Fundamentals

or chemical treatment, or both. Basics of MATLAB


Matrices and Vectors
Introducing Aspen Plus

The goal of applying such treatment steps is basically to add What Does Aspen Stand
For?

a value or convert the raw, cheap material(s) into valuable, What is Aspen Plus
process simulation model?

final finished products (gold).

The physical treatment steps may include mixing, separation


(de-mixing), such as absorption, distillation, and extraction,
and heating/cooling with or without a phase change.

On the other hand, the chemical treatment step involves a


single or set of parallel, series, or mixed reactions, which
results in a change of chemical identity of each of reacting
species.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 26 / 29


CAPD&S
Cont’
Tsegay G.

We can translate a process into an Aspen Plus process Programming


simulation model by performing the following skeletal Basics
MATLAB Fundamentals

necessary steps: Basics of MATLAB

1 Specify the chemical components in the process. We Matrices and Vectors


Introducing Aspen Plus

can fetch these components from Aspen Plus data What Does Aspen Stand
For?

banks, or we can introduce them to Aspen Plus What is Aspen Plus


process simulation model?

platform.
2 Specify thermodynamic models to represent the physical

properties of the components and mixtures in the


process. These models are built into Aspen Plus.
3 Define the process flowsheet

4 Specify the component flow rates and the

thermodynamic conditions (temperature, pressure, and


composition) of all feed streams.
5 Specify the operating conditions for the unit operation

models (i.e., blocks).


Tsegay G. (EiT-M) CAPD&S November 20, 2018 27 / 29
CAPD&S
Cont’
Tsegay G.

Programming
Basics
MATLAB Fundamentals
We can deliberately change any of the specifications listed in Basics of MATLAB

steps 1 − 5, such as flow-sheet scheme, operating conditions, Matrices and Vectors


Introducing Aspen Plus
and feed compositions, run the show, compare the new What Does Aspen Stand
For?

results with the old (previous) results, and then decide What is Aspen Plus
process simulation model?

whether to accept or reject new process alternatives.

Keep in mind that changing the list of components means


that we, in general, test for a new, alternative process type
rather than simply a modified version of the same process, in
terms of the type and number of physical and/or chemical
treatment steps, needed to end up with the same final,
finished product.

Tsegay G. (EiT-M) CAPD&S November 20, 2018 28 / 29


CAPD&S

Tsegay G.

Programming
Basics
MATLAB Fundamentals

Basics of MATLAB
Matrices and Vectors
Introducing Aspen Plus
What Does Aspen Stand
For?

THANK YOU What is Aspen Plus


process simulation model?

Tsegay G. (EiT-M) CAPD&S November 20, 2018 29 / 29

Potrebbero piacerti anche