In this tutorial we show how to model a physical system described by ODE using Xcos environment. The same model solution is also described in Scilab and Xcos + Modelica in two other tutorials.
Modeling an ODE: 3 different approaches - Part 3Scilab
In this tutorial we show how to model a physical system described by ODE using the Modelica extensions of the Xcos environment. The same model has been solved also with Scilab and Xcos in two previous tutorials.
Modeling an ODE: 3 different approaches - Part 1Scilab
In this tutorial we show how to model a physical system described by ODE using Scilab standard programming language. The same model solution is also described in Xcos and Xcos + Modelica in two other tutorials.
In this tutorial the reader can learn about data fitting, interpolation and approximation in Scilab. Interpolation is very important in industrial applications for data visualization and metamodeling.
Modeling an ODE: 3 different approaches - Part 3Scilab
In this tutorial we show how to model a physical system described by ODE using the Modelica extensions of the Xcos environment. The same model has been solved also with Scilab and Xcos in two previous tutorials.
Modeling an ODE: 3 different approaches - Part 1Scilab
In this tutorial we show how to model a physical system described by ODE using Scilab standard programming language. The same model solution is also described in Xcos and Xcos + Modelica in two other tutorials.
In this tutorial the reader can learn about data fitting, interpolation and approximation in Scilab. Interpolation is very important in industrial applications for data visualization and metamodeling.
In this Scilab tutorial, we introduce readers to the Control System Toolbox that is available in Scilab/Xcos and known as CACSD. This first tutorial is dedicated to "Linear Time Invariant" (LTI) systems and their representations in Scilab.
applet,applet life cycle,applet class,applet parameter,creating an executable applet,designing a web page:command section,head section,body section,applet tags,Graphics programming,Drawing polygons,drawing arcs,Drawing lines and rectangles
Presentation at NY Scala Enthusiasts Meetup on 6/14/2010. Covers techniques for using Scala's flexible syntax and features to design internal DSLs and wrappers.
The aim of this paper is to show the possibilities offered by Scilab/Xcos to model and simulate aeraulic and HVAC systems. In particular we develop a new Xcos module combined with the use of Modelica language to show how aeraulic systems can be modeled and studied. In this paper we construct a reduced library composed by few elements: hoods, pipes and ideal junctions. The library can be easily extended to obtain a more complete toolbox. The developed library is tested on a simple aeraulic circuit.
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
Virtual Method Table and accident preventionAndrey Karpov
As a small warm-up before the article, I would like readers to ask themselves: does a photographer need
to know how camera works in order to make qualitative photos? Well, does he need to know the term
"diaphragm" at least? "Signal-to-noise ratio"? "Depth of field"? Practice shows that even with a
knowledge of such difficult terms photos shot by the most "gifted ones" may be just a little bit better
that photos shot by cell phone camera through 0.3 MP "hole". Alternatively, good quality photos may be
shot due to the outstanding experience and intuition without any knowledge whatsoever (but usually it
is an exception to the rules). Nevertheless, it is unlikely that there is somebody who can argue with me
in the fact that professionals who want to get every single possibility from their camera (not only MP in
a square millimeter on an image sensor) are required to know these terms, or else they cannot be called
professionals at all. That is true not only in digital photography, but in almost every other industry as
well.
The purpose of this document is to guide you step by step in exploring the various basic features of Xcos for a user who has never used a hybrid dynamic systems modeler and simulator.
Customizing Xcos with new Blocks and PaletteScilab
In this tutorial, we show how to create and customize Xcos blocks and palettes. Moreover, we use the "Xcos toolbox skeleton" for a better result. The LHY model in Xcos scheme (already developed in other tutorials) is used as a starting point.
In this Scilab tutorial, we introduce readers to the Control System Toolbox that is available in Scilab/Xcos and known as CACSD. This first tutorial is dedicated to "Linear Time Invariant" (LTI) systems and their representations in Scilab.
applet,applet life cycle,applet class,applet parameter,creating an executable applet,designing a web page:command section,head section,body section,applet tags,Graphics programming,Drawing polygons,drawing arcs,Drawing lines and rectangles
Presentation at NY Scala Enthusiasts Meetup on 6/14/2010. Covers techniques for using Scala's flexible syntax and features to design internal DSLs and wrappers.
The aim of this paper is to show the possibilities offered by Scilab/Xcos to model and simulate aeraulic and HVAC systems. In particular we develop a new Xcos module combined with the use of Modelica language to show how aeraulic systems can be modeled and studied. In this paper we construct a reduced library composed by few elements: hoods, pipes and ideal junctions. The library can be easily extended to obtain a more complete toolbox. The developed library is tested on a simple aeraulic circuit.
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
Virtual Method Table and accident preventionAndrey Karpov
As a small warm-up before the article, I would like readers to ask themselves: does a photographer need
to know how camera works in order to make qualitative photos? Well, does he need to know the term
"diaphragm" at least? "Signal-to-noise ratio"? "Depth of field"? Practice shows that even with a
knowledge of such difficult terms photos shot by the most "gifted ones" may be just a little bit better
that photos shot by cell phone camera through 0.3 MP "hole". Alternatively, good quality photos may be
shot due to the outstanding experience and intuition without any knowledge whatsoever (but usually it
is an exception to the rules). Nevertheless, it is unlikely that there is somebody who can argue with me
in the fact that professionals who want to get every single possibility from their camera (not only MP in
a square millimeter on an image sensor) are required to know these terms, or else they cannot be called
professionals at all. That is true not only in digital photography, but in almost every other industry as
well.
The purpose of this document is to guide you step by step in exploring the various basic features of Xcos for a user who has never used a hybrid dynamic systems modeler and simulator.
Customizing Xcos with new Blocks and PaletteScilab
In this tutorial, we show how to create and customize Xcos blocks and palettes. Moreover, we use the "Xcos toolbox skeleton" for a better result. The LHY model in Xcos scheme (already developed in other tutorials) is used as a starting point.
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...IJRES Journal
Based on studying active disturbance rejection control technology, a user defined Active Disturbance Rejection Controller (ADRC) block library was established in MATLAB / SIMULINK, by the way of developing M-function files for special nonlinear function and the subsystem packaging technology of building system modules for Tracking Differentiator(TD), Extended State Observer(ESO) and Non Linear State Error Feedback(NLSEF). The simulation example shows that the ADRC simulation model can be built in graphic modeling method, and the block parameters are easy to modify by using the defined ADRC module. Furthermore, the way to create new ADRC block library is simple and the library is easy to extend. Meanwhile it is a useful tool for searching and simulation of active disturbance rejection control technology.
A sliding door is a type of door which opens horizontally by sliding, whereby the door is either mounted on or suspended from a track. Some sliding doors contain a motor and activation system to open them. These are called sliding door operators. Sliding door operators are typically used on the outside doors of large retail businesses.
A sliding door operator reopens the door if it closes into an obstacle. However, most operators use sensors to prevent the door from ever coming into contact with a user in the first place.
The simplest sensor is a light beam across the opening. An obstacle in the path of the closing door breaks the beam, indicating its presence. Infrared and radar safety sensors are also commonly used.
AN IMPROVED DECISION SUPPORT SYSTEM BASED ON THE BDM (BIT DECISION MAKING) ME...ijmpict
Based on the BDM (Bit Decision Making) method, the present work presents two contributions: first, the
illustration of the use of the technique known as SOP (Sum Of Products) in order to systematize the
process to obtain the correlation function for sub-system’s mathematical modelling, and second,the provision of capacity to manage a greater than binary but a finite - discrete set of possible subjective qualifications of suppliers at any criterion.
The following resources come from the 2009/10 BEng in Digital Systems and Computer Engineering (course number 2ELE0065) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes.
The objectives of this module are to demonstrate, within an embedded development environment:
• Processor – to – processor communication
• Multiple processors to perform one computation task using parallel processing
This project requires the establishment of a communication protocol between two 68000-based microcomputer systems. Using ‘C’, students will write software to control all aspects of complex data transfer system, demonstrating knowledge of handshaking, transmission protocols, transmission overhead, bandwidth, memory addressing. Students will then demonstrate and analyse parallel processing of a mathematical problem using two processors. This project requires two students working as a team.
Title:
Hands-on-OpenIPSL.org using OpenModelica!
Instructor:
Luigi Vanfretti, PhD - RPI
luigi.vanfretti@gmail.com
Abstract:
The Modelica language, being standardized and equation-based, has proven valuable for the for model exchange, simulation and even for model validation applications in actual power systems. These important features have been now recognized by the European Network of Transmission System Operators, which have adopted the Modelica language for dynamic model exchange in the Common Grid Model Exchange Standard (v2.5, Annex F).
Following previous FP7 project results, within the ITEA 3 openCPS project, the presenters have continued the efforts of using the Modelica language for power system modeling and simulation, by developing and maintaining the OpenIPSL library: http://openipsl.org
This tutorial will follow the seminar introducing OpenIPSL.org and give you hands-on-experience on using the library using the OpenModelica modeling and simulation environment.
It is assumed that you have very little experience with OpenModelica and the Modelica language, so detailed instructions are provided.
You will need to bring your computer with OpenModelica installed, see the following link for a .pdf information on installation: https://goo.gl/oLAFv4
You will be working with three examples. In the first example, you will work setting up a power system from scratch and performing simulations using OpenModelica and the OpenIPSL. The second example consists on performing linear analysis using OMNotebook, and implementing a power system stabilizer for the model of example one. Finally, in the third example, you will perform simulations of a typical IEEE 9-Bus power systems and perform a simple analysis of results.
Bio:
Luigi Vanfretti (SMIEEE’14) obtained the M.Sc. and Ph.D. degrees in electric power engineering at Rensselaer Polytechnic Institute, Troy, NY, USA, in 2007 and 2009, respectively.
He was with KTH Royal Institute of Technology, Stockholm, Sweden, as Assistant 2010-2013), and Associate Professor (Tenured) and Docent (2013-2017/August); where he lead the SmarTS Lab and research group. He also worked at Statnett SF, the Norwegian electric power transmission system operator, as consultant (2011 - 2012), and Special Advisor in R&D (2013 - 2016).
He joined Rensselaer Polytechnic Institute in August 2017, to continue to develop his research at ALSETLab: http://alsetlab.com
His research interests are in the area of synchrophasor technology applications; and cyber-physical power system modeling, simulation, stability and control.
EFFICIENT IMPLEMENTATION OF 16-BIT MULTIPLIER-ACCUMULATOR USING RADIX-2 MODIF...VLSICS Design
In this paper, we propose a new multiplier-and-accumulator (MAC) architecture for low power and high speed arithmetic. High speed and low power MAC units are required for applications of digital signal processing like Fast Fourier Transform, Finite Impulse Response filters, convolution etc. For improving the speed and reducing the dynamic power, there is a need to reduce the glitches (1 to 0 transition) and spikes (0 to 1 transition). Adder designed using spurious power suppression technique (SPST) avoids the unwanted glitches and spikes, thus minimizing the switching power dissipation and hence the dynamic power. Radix -2 modified booth algorithm reduces the number of partial products to half by grouping of bits from the multiplier term, which improves the speed. The proposed radix-2 modified Booth algorithm
MAC with SPST gives a factor of 5 less delay and 7% less power consumption as compared to array MAC
Why electric vehicles need model-based design?
Because of the rising complexity in new vehicles, model-based design & systems engineering is needed to cascade the requirements and trace back any modification along the engineering lifecycle. Find out more in this presentation of a customer case about electric motor optimization.
Keynote of the French Space Agency CNES on the Asteroidlander MASCOT boarding the Hayabusa2 mission in collaboration with the Japanese Space Agency JAXA and the German Aerospace Center DLR
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...Scilab
Rapid Prototyping becomes very popular for faster algorithm development. With a graphical representation of the algorithm and the possibility to simulate complete designs, engineers can help to reduce the time to market. A tight integration with MPLAB-X IDE allows the combination with standard C-coding to easily get mass production code. This solution was used to optimise a sensorless field oriented controlled PMSM motor driven pump efficiency. A model for closed loop simulation was developed using X2C blocks [1][2] for the FOC algorithm based on the existing application note AN1292 [3]. Enhancements to the original version were implemented and verified with simulation. The X2C Communicator was used to generate code of the new algorithm. With the online debugging capabilities and the scope functionality the algorithm was further tuned and optimized to achieve the highest possible efficiency of the pump.
Scilab and Xcos for Very Low Earth Orbits satellites modellingScilab
Very Low Earth Orbits are orbits in altitudes lower than 450 km. The interaction between the atmosphere particles and the surfaces of the spacecraft is responsible for the aerodynamic torques and forces. Simulating several aspects of the performance of a satellite flying in VLEO is very important to make decisions about the design of the spacecraft and the mission.
X2C -a tool for model-based control development and automated code generation...Scilab
Peter Dirnberger, Stefan Fragner
Nowadays, the market demands compact, stable, easy maintain-and customizable embedded systems. To meet these requirements, afast, simple and reliable implementation of control algorithms is crucial. This paper demonstrateshow model-based design with the help of Scilab/Xcosand X2C, developed by LCM,simplifiesand speedsup the development and implementation of controlalgorithms. As an example, acontrol schemefor a bearingless motoris presented.
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...Scilab
As part of an EU-founded research project, the Scilab based development tool LoRra (Low-Cost Rapid Control Prototyping Platform) was created. This allows the realization of the continuously model based and highly automated Rapid Control Prototyping (RCP) design process for embedded software within the Scilab / Xcos environment (cf. Figure 1). Based on the application battery management system (BMS), this paper presents a Real-Time interface for Scilab.
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCosScilab
The increasing demand in the aerospace industry for safety and performance has been requiring even more resourceful flight control laws in all market segments, since the airliners until the newest flying cars. The de facto standard for flight control laws design makes extensive use of tools supporting numerical computing and dynamic systems visual modeling, such that Scilab and XCos can nicely suit this kind of development.
Multiobjective optimization and Genetic algorithms in ScilabScilab
In this Scilab tutorial we discuss about the importance of multiobjective optimization and we give an overview of all possible Pareto frontiers. Moreover we show how to use the NSGA-II algorithm available in Scilab.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
Low power architecture of logic gates using adiabatic techniquesnooriasukmaningtyas
The growing significance of portable systems to limit power consumption in ultra-large-scale-integration chips of very high density, has recently led to rapid and inventive progresses in low-power design. The most effective technique is adiabatic logic circuit design in energy-efficient hardware. This paper presents two adiabatic approaches for the design of low power circuits, modified positive feedback adiabatic logic (modified PFAL) and the other is direct current diode based positive feedback adiabatic logic (DC-DB PFAL). Logic gates are the preliminary components in any digital circuit design. By improving the performance of basic gates, one can improvise the whole system performance. In this paper proposed circuit design of the low power architecture of OR/NOR, AND/NAND, and XOR/XNOR gates are presented using the said approaches and their results are analyzed for powerdissipation, delay, power-delay-product and rise time and compared with the other adiabatic techniques along with the conventional complementary metal oxide semiconductor (CMOS) designs reported in the literature. It has been found that the designs with DC-DB PFAL technique outperform with the percentage improvement of 65% for NOR gate and 7% for NAND gate and 34% for XNOR gate over the modified PFAL techniques at 10 MHz respectively.
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
Online aptitude test management system project report.pdfKamal Acharya
The purpose of on-line aptitude test system is to take online test in an efficient manner and no time wasting for checking the paper. The main objective of on-line aptitude test system is to efficiently evaluate the candidate thoroughly through a fully automated system that not only saves lot of time but also gives fast results. For students they give papers according to their convenience and time and there is no need of using extra thing like paper, pen etc. This can be used in educational institutions as well as in corporate world. Can be used anywhere any time as it is a web based application (user Location doesn’t matter). No restriction that examiner has to be present when the candidate takes the test.
Every time when lecturers/professors need to conduct examinations they have to sit down think about the questions and then create a whole new set of questions for each and every exam. In some cases the professor may want to give an open book online exam that is the student can take the exam any time anywhere, but the student might have to answer the questions in a limited time period. The professor may want to change the sequence of questions for every student. The problem that a student has is whenever a date for the exam is declared the student has to take it and there is no way he can take it at some other time. This project will create an interface for the examiner to create and store questions in a repository. It will also create an interface for the student to take examinations at his convenience and the questions and/or exams may be timed. Thereby creating an application which can be used by examiners and examinee’s simultaneously.
Examination System is very useful for Teachers/Professors. As in the teaching profession, you are responsible for writing question papers. In the conventional method, you write the question paper on paper, keep question papers separate from answers and all this information you have to keep in a locker to avoid unauthorized access. Using the Examination System you can create a question paper and everything will be written to a single exam file in encrypted format. You can set the General and Administrator password to avoid unauthorized access to your question paper. Every time you start the examination, the program shuffles all the questions and selects them randomly from the database, which reduces the chances of memorizing the questions.
1. www.openeering.com
powered by
MODELING IN SCILAB: PAY ATTENTION TO THE RIGHT
APPROACH – PART 2
In this tutorial we show how to model a physical system described by ODE using
Xcos environment. The same model solution is also described in Scilab and Xcos
+ Modelica in two other tutorials.
Level
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
2. LHY Tutorial Xcos www.openeering.com page 2/19
Step 1: The purpose of this tutorial
In Scilab there are three different approaches (see figure) for modeling
a physical system which is described by Ordinary Differential Equations
(ODE).
For showing all these capabilities we selected a common physical
system, the LHY model for drug abuse. This model is used in our
tutorials as a common problem to show the main features of each
strategy. We are going to recurrently refer to this problem to allow the
reader to better focus on the Scilab approach rather than on mathematical
details.
In this second tutorial we show, step by step, how the LHY model problem
can be implemented in the Xcos environment. The sample code can be
downloaded from the Openeering web site.
1 Standard Scilab
Programming
2 Xcos Programming
3 Xcos + Modelica
Step 2: Model description
The considered model is the LHY model used in the study of drug abuse.
This model is a continuous-time dynamical system of drug demand for two
different classes of users: light users (denoted by ) and heavy users
(denoted by ) which are functions of time . There is another state in
the model that represents the decaying memory of heavy users in the
years (denoted by ) that acts as a deterrent for new light users. In
other words the increase of the deterrent power of memory of drug abuse
reduces the contagious aspect of initiation. This approach presents a
positive feedback which corresponds to the fact that light users promote
initiation of new users and, moreover, it presents a negative feedback
which corresponds to the fact that heavy users have a negative impact on
initiation. Light users become heavy users at the rate of escalation
and leave this state at the rate of desistance . The heavy users leave
this state at the rate of desistance .
3. LHY Tutorial Xcos www.openeering.com page 3/19
Step 3: Mathematical model
The mathematical model is a system of ODE (Ordinary Differential
Equation) in the unknowns:
, number of light users;
, number of heavy users;
, decaying of heavy user years.
The initiation function contains a “spontaneous” initiation and a
memory effect modeled with a negative exponential as a function of the
memory of year of drug abuse relative to the number of current light users.
The problem is completed with the specification of the initial conditions
at the time .
The LHY equations system (omitting time variable for sake of simplicity) is
{
̇
̇
̇
where the initiation function is
{ }
The LHY initial conditions are
{
4. LHY Tutorial Xcos www.openeering.com page 4/19
Step 4: Problem data
(Model data)
: the annual rate at which light users quit
: the annual rate at which light users escalate to heavy use
: the annual rate at which heavy users quit
: the forgetting rate
(Initiation function)
: the number of innovators per year
: the annual rate at which light users attract non-users
: the constant which measures the deterrent effect of heavy use
: the maximum rate of generation for initiation
(Initial conditions)
: the initial simulation time;
: Light users at the initial time;
: Heavy users at the initial time;
: Decaying heavy users at the initial time.
Model data
Initiation function
Initial conditions
5. LHY Tutorial Xcos www.openeering.com page 5/19
Step 5: Xcos programming – introduction
Xcos is a free graphical editor and simulator based on Scilab that helps
people to model physical systems (electrical, mechanical, automotive,
hydraulics, …) using a graphical user interface based on a block diagram
approach. It includes explicit and implicit dynamical systems and both
continuous and discrete sub-systems.
This toolbox is particularly useful in control theory, digital and signal
processing and model-based design for multidomain simulation, especially
when continuous time and discrete time components are interconnected.
As an example of a Xcos diagram, we show on the right a Xcos model of
a RLC electric circuit with its graphical output. The first output is relative to
the voltage across the capacitor element, while the second one is relative
to the current through the voltage generator.
6. LHY Tutorial Xcos www.openeering.com page 6/19
Step 6: Xcos programming – getting started
Xcos environment can be started from Scilab Console typing
--> xcos
or clicking on the button in the Scilab menu bar.
The command starts two windows:
the palette browser that contains all Xcos available blocks
grouped by categories;
an editor window where the user can drag blocks from the
palette browser for composing new schemes.
All Xcos files end with extension “.zcos”. In previous versions of Scilab all
Xcos files end with extension “.xcos”.
7. LHY Tutorial Xcos www.openeering.com page 7/19
Step 7: Xcos programming – block types
In Xcos the main object is a block that can be used in different models
and projects.
A Xcos block is an element characterized by the following features:
input/output ports; input/output activations ports; continuous/discrete time
states; …
Xcos blocks contain several type of links:
Regular links that transmit signals through the blocks ports
(black triangle);
Activation links that transmit activation timing information
through the block ports (red triangle);
Implicit links, see tutorial Xcos + Modelica (black square).
The user should connect only ports of the same type.
Block configuration can be specified from the input mask by double-
clicking on the block.
Step 8: Roadmap
In this tutorial we describe how to construct the LHY model and simulate it
in Xcos. We :
provide a description of all the basic blocks used for the LHY
model;
provide a description of the simulation menu;
provide a description of how to edit a model;
construct the LHY scheme;
test the program and visualize the results.
Descriptions Steps
Basic blocks 9-16
Simulation menu 17-19
Editing models 20-22
Scheme construction 23-27
Test and visualize 28
8. LHY Tutorial Xcos www.openeering.com page 8/19
Step 9:The integral block
Palette: Continuous time systems / INTEGRAL_m
Purpose: The output of the block y(t) is the integral of the input u(t)
at the current time step t .
In our simulation we use this block to recover the variable L(t) starting
from its derivative L’(t). The initial condition can be specified in the
input mask.
Hint: Numerically it is always more robust using the integral block instead
of the derivative block.
The integral block
Step 10: The sum block
Palette: Math operations / BIGSOM_f
Purpose: The output of the block y(t) is the sum with sign of the input
signals. The sign of the sum can be specified from the input mask with
“+1” for “+” and “-1” for “-”.
The sum block
Step 11: The gain block
Palette: Math operations / GAINBLK_f
Purpose: The output of the block y(t) is the input signal u(t)
multiplied by the gain factor. The value of the gain constant can be
specified from the input mask.
The gain block
9. LHY Tutorial Xcos www.openeering.com page 9/19
Step 12: The expression block
Palette: User defined functions / EXPRESSION
Purpose: The output of the block y is a mathematical combination of
the input signals u1,u2,…,uN (max 8). The name, u, followed by a
number, is mandatory. More precisely, u1 represents the first input port
signal, u2 represents the second input port signal, and so on.
Note that constants that appear in the expression must first be defined in
the “context menu” before their use.
The expression block
Step 13: The clock block
Palette: Sources / CLOCK_c
Purpose: This block generates a regular sequence of time events with a
specified period and starting at a given initialization time. We use this
block to activate the scope block (see next step) with the desired
frequency.
The clock block
Step 14: The scope block
Palette: Sinks / CSCOPE
Purpose: This block is used to display the input signal (also vector of
signals) with respect to the simulation time. For a better visualization it
may be necessary to specify the scope parameters like ymin, ymax
values.
The scope block
10. LHY Tutorial Xcos www.openeering.com page 10/19
Step 15: The multiplexer block
Palette: Signal routing / MUX
Purpose: This block merges the input signals (maximum 8) into a unique
vector output signal. We use this block for plotting more signals in the
same windows. The number of input ports can be specified from the input
mask.
The multiplexer block
Step 16: The annotation block
Palette: Annotations palette / TEXT_f
Purpose: This block permits to add comments to the scheme. Comments
can also be in LaTex coding. This block can be also called by a double
click of the mouse on the scheme.
Examples of LaTex code are $L$ for generating L and $dot L$ for
generating L’(t).
The annotation block
Step 17: The simulation starting time
Each Xcos simulation starts from the initial time 0 and ends at a
specified final time.
The ending simulation time should be specified in the
"Simulation/Setup" menu in the "Final integration time"
field.
Simulation starting time is 0 !
11. LHY Tutorial Xcos www.openeering.com page 11/19
Step 18: Set simulation parameters
The simulation parameters such as the “final integration time” and solver
tolerances can be specified from the “set parameters” dialog in the
"Simulation/Setup" menu.
Step 19: Set Context
The model constants used in the block definitions can be entered in the
“simulation set context”. This menu is available from the
"Simulation/Set Context" menu.
In our simulation we set here all the model constants and the initial
conditions, such that it is easier to change the model value for a new
simulation since all the constants are available in an unique place.
12. LHY Tutorial Xcos www.openeering.com page 12/19
Step 20: Editing the model : Align blocks
Here we report some hints to improve the visual quality of the connections
between blocks. The first step is to drag some elements in the diagram
and align them.
To make a selection:
Left-click where you want to start your selection;
Hold down your left mouse button and drag the mouse until you
have highlighted the area you want;
or
Left-click of the mouse over the element you want;
Ctrl + Left-click on elements that you want to select;
To align elements:
Right-click of the mouse and select: Format -> Align Blocks
-> Center.
(before)
(after)
13. LHY Tutorial Xcos www.openeering.com page 13/19
Step 21: Editing the model : intermediate points
You can link elements specifying the path using a mouse click on
intermediate points.
Starting configuration
Intermediate path
Final path
14. LHY Tutorial Xcos www.openeering.com page 14/19
Step 22: Editing the model
The same if you want to link elements to an already existing path (start
from the element port and draw the path you want). Click with the mouse
at the right position although the visualization is not correct.
Starting configuration
Intermediate path
Final path
15. LHY Tutorial Xcos www.openeering.com page 15/19
Step 23: Make the LHY scheme
Set the “Final integration time” to 50 in the "Simulation/Setup" menu;
In our simulation we modify the value of the “Final integration time” to 50
because the initial time in Xcos is 0, which corresponds to the year 1970
of our model. This means that 50 corresponds to the year 2020 of our
model.
Step 24: Make the LHY scheme
Set the model constants in the "Simulation/Set Context" menu.;
tau = 5e4; // Number of innovators per year
(initiation)
s = 0.61; // Annual rate at which light users
attract non-users (initiation)
q = 3.443; // Constant which measures the deterrent
effect of heavy users (initiation)
smax = 0.1; // Upper bound for s effective
(initiation)
a = 0.163; // Annual rate at which light users quit
b = 0.024; // Annual rate at which light users
escalate to heavy use
g = 0.062; // Annual rate at which heavy users quit
delta = 0.291; // Forgetting rate
// Initial conditions
Tbegin = 1970; // Initial time
Tend = 2020; // Final time
Tstep = 0.5; // Time step
L0 = 1.4e6; // Light users at the initial time
H0 = 0.13e6; // Heavy users at the initial time
Y0 = 0.11e6; // Decaying heavy user at the initial
time
16. LHY Tutorial Xcos www.openeering.com page 16/19
Step 25: Make the LHY scheme
Drag integration blocks and specify for each blocks the appropriate initial
conditions.
Add also some annotations.
17. LHY Tutorial Xcos www.openeering.com page 17/19
Step 26: Make the LHY scheme
Add:
Three sum blocks;
Three integral blocks;
Four gain blocks with the appropriate constants;
A multiplexer block (4 ports: );
A scope block (ymin = 0, ymax = 9e+6, Refresh period =
50);
A clock block (Period=0.5, Initiation = 0).
Connect the blocks as shown in the figure. For a more readable diagram it
is better to comment blocks and connections using annotation blocks as
reported in the figure.
Step 27: Make the LHY scheme
Add:
One expression block (with two inputs and the Scilab expression
tau + max(smax,s*exp(-q*u2/u1))*u1);
18. LHY Tutorial Xcos www.openeering.com page 18/19
Step 28: Running and testing
Click on the menu button .
Step 13: Exercise #1
Modify the main program file such that it is possible to write data to Scilab
environment and plot data from Scilab.
Hint:
Use the block in “Sinks” “To workspace” as reported on the right.
19. LHY Tutorial Xcos www.openeering.com page 19/19
Step 14: Concluding remarks and References
In this tutorial we have shown how the LHY model can be implemented in
Scilab/Xcos
On the right-hand column you may find a list of references for further
studies.
1. Scilab Web Page: Available: www.scilab.org.
2. Openeering: www.openeering.com.
3. D. Winkler, J. P. Caulkins, D. A. Behrens and G. Tragler, "Estimating
the relative efficiency of various forms of prevention at different
stages of a drug epidemic," Heinz Research, 2002.
http://repository.cmu.edu/heinzworks/211/.
Step 15: Software content
To report a bug or suggest some improvement please contact Openeering
team at the web site www.openeering.com.
Thank you for your attention,
Manolo Venturin
------------------------
LHY MODEL IN SCILAB/XCOS
------------------------
--------------
Main directory
--------------
ex1.xcos : Solution of the exercise
LHY_Tutorial_Xcos.xcos : Main xcos program
license.txt : The license file