SlideShare a Scribd company logo
West Lab
Modelica Tutorial
1
West Lab
OpenModelica
• OS
- Linux
- Windows
- Mac
ØPartly supported
ØInstall
• Homebrew
• Macport
- Virtual Machine (ubuntu)
Ø https://openmodelica.org/download/virtual-
machine
Ø Installation
1. Install virtualbox
2. Download box file, and vmdk file in same
directory
3. Double click the box file
Ø Bug: cannot login
• Change GUI manager
2
West Lab
3
1. Modelica introduction
2. Thermal simulation using Modelica
3. Exercise1: RL Circuit
4. Exercise2: Transmission Loss
5. Exercise3: Power World
West Lab
What is Modelica?
4
TUTORIAL – COURSE
Introduction to Object-Oriented
Modeling and Simulation with Modelica
Using OpenModelica
Peter Fritzson
Copyright (c) Open Source Modelica Consortium
Version 2012
https://www.modelica.org/libraries
A language for modeling of
complex physical system.
Primarydesigned for simulation.
West Lab
What is Modelica?
5
TUTORIAL – COURSE
Introduction to Object-Oriented
Modeling and Simulation with Modelica
Using OpenModelica
Peter Fritzson
Copyright (c) Open Source Modelica Consortium
Version 2012
https://www.modelica.org/libraries
A language for modeling of
complex physical system.
Combine multi-domainmodeling
West Lab
What is Modelica?
6
Declarative language
Equations and mathematicalfunctions allow acausal modeling,
high level specification,increasedcorrectness
Multi-domain modeling
Combine electrical,mechanical,thermodynamic,hydraulic,
biological,control,event, real-time,etc…
Everything is a class
Strongly typed object-orientedlanguage with a general class
concept, Java & MATLAB-like syntax
Visual component programming
Hierarchical system architecture capabilities
Efficient, non-proprietary
Efficiencycomparable to C; advanced equation compilation,
e.g. 300 000 equations,~ 150 000 lines on standard PC
West Lab
Free/Commercial tools
• Simulator
- Commercial
ØDymola
ØCyModelica
ØWoflram
ØSimulationX
- Free
ØOpenModelica
ØJModelica.org
ØModelicac
• Editor
- Modelica mode for emacs
- UltraEdit
- Modelica Plugin (for Eclipse)
- Modelica Sublime Text Package
- OMEditor
7
• Developer site
- https://modelica.org/tools
West Lab
Modelica Free/Commercial Libraries
8
• Modelica Library
- Modelica
- Power system
- Vehicle
- Mathematics
- Chemical
- Building
https://www.modelica.org/libraries
West Lab
Modelica Tutorial
9
• Exercise 1
- RL Circuit model
• Exercise 2
- TransmissionLoss model
• Exercise 3
- Power World
West Lab
Exercise 1: RL Circuit
10
• Goal
- Making a basic RL circuit model using Modelica language
- Executing a simulationand plottingthe result
- Understanding the relationshipbetween electrical-thermalenergy
• Library
- Modelica library
West Lab
Exercise 1: RLC Circuit Modeling
11
Open	the	OMEdit
West Lab
12
1. Make	a	new	Package	“RLCircuit”
2. Make	a	new	Model	“Resistor”
3. Add	a	extends	model
4. Add	a	parameter	“R”
5. Add	a	equation
West Lab
13
extends	Modelica.Electrical.Analog.Interfaces.OnePort;
parameter	Modelica.SIunits.Resistance R(start=1);
equation
v	=	R	*	i;
West Lab
14
West Lab
15
“partial”	means	this	model	is	incomplete
West Lab
16
SI	=>	Modelica.SIunits
import	SI	=	Modelica.SIunits;
West Lab
17
model	Resistor
equation
v	=	p.v - nv;
0	=	p.i - n.i;
i =	p.i;
v	=	R	*	i;
end	Resistor
West Lab
18
You	can	check	your	code	here
West Lab
19
1. Make	a	new	model	“RLCircuit”	in	RLCircuit package
2. Add	Inductor,	Ground,	 and	sinVoltage from	
Modelica.Electrical.Analog,	and	Resistor
3. Connect	each	other
West Lab
20
1. Change	the	stoptime
2. simulate	the	model
West Lab
Exercise 1: Simulation result
21
Choose	the	resistor1.v
West Lab
22
1. Right	click	the	RLCircuit
2. Click	the	“Duplicate”
3. Choose	RLCircuit package	as	the	“Path”
4. Choose	the	new	model
West Lab
23
1. Right	click	the	resistance
2. Delete	the	block
3. Replace	the	resistance	to	
Modelica.Electrical.Analog.Basic.Resistor
West Lab
24
1. Add	FixedTemperature from	
Modelica.Thermal.HeatTransfer.Sources.FixedTemperature
2. Connect	to	the	replaced	resistor
West Lab
25
West Lab
26
Simulation	results
1. Click	the	LossPower and	v	in	RLCircuit2
2. Compare	the	result
West Lab
27
New	plot	window
West Lab
Exercise 2: Transmission Loss
28
• Goal
- Making a simple model representingtransmissionloss
using PowerSystems library
- Using the icon setting
- Understanding the outer/inner variables
• Library
- PowerSystems
West Lab
29
1. Open	File->System	Libraries->PowerSystems
2. Make	a	new	model
West Lab
30
extends	PowerSystems.Basic.Icons.Block;
Icon setting
West Lab
31
Click	the	icon	view
Icon setting
West Lab
32
Icon setting
West Lab
33
1. Extend	PartialTwoTerminal
2. Add	three	variables
You	can	search	the	PartialTwoTerminal here
Parameter of the line model
West Lab
34
West Lab
35
Replaceable	package	inherits	all	functions/variables/settings	
from	PowerSystems library
Every	model	in	PowerSystems inherits	this	PhaseSystem
• DC	or	AC
• Phase	number
• Frequency
West Lab
36
1. Add	equation
PhaseSystem.m:	Number	of	reference	angle
DC:	m	=	0
AC:	m	>	0	
Equation of the line model
West Lab
37
if	PhaseSystem.m >	0	then
omegaRef =	der(PhaseSystem.thetaRef(terminal_p.theta));
else
omegaRef =	0;
end	if;
v	=	R	*	i +	omegaRef *	L	*	j(i);
zeros(PhaseSystem.n)	=	terminal_p.i +	terminal_n.i;
if	PhaseSystem.m >	0	then
terminal_p.theta =	terminal_n.theta;
end	if
Equation of the line model
West Lab
38
Simulationof the line model
West Lab
39
1. Set	1.	FixedVoltageSource,	 2.	FixedCurrennt,	and	3.	System	
from	Powersystem.Generic
2. Open	the	parameter	window	of	the	FixedCurrent by	double	
click	and	change	the	parameter
Simulationof the line model
West Lab
40
1. Set	1.	FixedVoltageSource,	 2.	FixedCurrennt,	and	3.	System	
from	Powersystem.Generic
2. Open	the	parameter	window	of	the	FixedCurrent by	double	
click	and	change	the	parameter
Simulationof the line model
West Lab
41
1. Confirm	your	code	is	correct
Simulationof the line model
West Lab
42
System:	an	interface	of	PhaseSystem setting
”inner”	works	as	a	global	variable
• Omega,	theta,	and	frequency	
• DC/AC/AC(3phase)
• Initial	value
Simulationof the line model
West Lab
43
System:	an	interface	of	PhaseSystem setting
”inner”	works	as	a	global	variable
• Omega,	theta,	and	frequency	
• DC/AC/AC(3phase)
• Initial	value
inner	PowerSystems.Systemsystem(…
Simulationof the line model
West Lab
44
*	Modelica	Advanced	Tutorial:	Developing	Modeling	Library,	Martin	Otter,	Hilding	Elmqvist
West Lab
45
By	clicking	the	information	 button,	you	can	
see	the	detailed	information	 of	the	“System”.
Simulationof the line model
West Lab
46
The	result	is	constant	value
Simulationof the line model
West Lab
Exercise 3: Power World
47
• Goal
- Simulatingthe simplifiedpower grid including
ØVoltage
ØCurrent
ØFrequency
- Considering transmissionloss,and voltage conversion
- Using dynamic wind and electricityconsumptiondata
• Library
- PowerSystems
* The Power World uses Generic components
with the quasi-static ThreePhase_dq because
fast electrical transients and asymmetries are
neglected. For more precise simulation of
power grid, you can use the SPOT from
PowerSystems supporting AC 3 phase.
West Lab
Exercise 3: Power World
48
• Goal
- Simulatingthe simplifiedpower grid including
ØVoltage
ØCurrent
ØFrequency
- Considering transmissionloss,and voltage conversion
- Using dynamic wind and electricityconsumptiondata
• Library
- PowerSystems
* The Power World uses Generic components
with the quasi-static ThreePhase_dq because
fast electrical transients and asymmetries are
neglected. For more precise simulation of
power grid, you can use the SPOT from
PowerSystems supporting AC 3 phase.
West Lab
49
Exercise 3: Power World
1. Add	System	from	PowerSystems
2. Add	PowerPlant,	HydroPlant,	WindFarm,	and	City	
from	PowerSystems.Examples.Components
West Lab
50
You	can	check	the	content	by
1. Right	click	the	block
2. Choose	“Open	Class"
Exercise 3: Power World
West Lab
51
Exercise 3: Power World
West Lab
52
1. Click	the	“Text	View”
2. Change	the	WindFarm setting
Exercise 3: Power World
West Lab
53
windFarm1(redeclare package	PhaseSystem =	PowerSystems.PhaseSystems.DirectCurrent)
Exercise 3: Power World
West Lab
54
1. Add	VoltageConverter,	
Inverter	and	line
2. Double	click	and	change	
the	parameter	of	
VoltageConverter to	380/50
3. Double	click	and	change	
the	PotentialReference of	
Inverter	to	false
Exercise 3: Power World
West Lab
55
1. Add	VoltageConverter,	
Inverter	and	line
2. Double	click	and	change	
the	parameter	of	
VoltageConverter to	380/10
Exercise 3: Power World
West Lab
56
1. Add	LoadDispatcher from	
PowerSystems.Example.PowerWorld.Components
2. Add	RealExpression from	Modelica.Blocks.Sources
Exercise 3: Power World
West Lab
57
1. Double	click	the	RealExpression
2. Set	the	output	“y”	as	“system.omega/2/pi”
Exercise 3: Power World
West Lab
58
“pi”	is	defined	in	Modelica.Constants
1. Click	“Text	View”
2. Add	”import	Modelica.Constants.pi;”
Exercise 3: Power World
West Lab
59
1. Just	click	“OK”	when	you	connect	
the	LoadDispatcher and	Plants
Exercise 3: Power World
West Lab
60
Exercise 3: Power World
1. Double	click	the	”system”
2. Change	ini to	“tr”	(double	 quotation	is	required)
3. Change	ftype_par to	false
West Lab
61
Exercise 3: Power World
1. Change	the	stoptime to	86400
60	(sec)	*	60	*	24	=	86400
West Lab
62
Simulationresult: Electricitydemand and supply
West Lab
63
Simulationresult: Wind
West Lab
64
Simulationresult: Frequency
West Lab
65
Simulationresult: Frequency
In	the	system,	simulation	is	terminated	
when	the	frequency	exceed	the	limitation.
West Lab
66
Two Windfarm model
West Lab
67
Two Windfarm model
West Lab
SPOT: more precise power-system simulation
68
* The Power World uses Generic components
with the quasi-static ThreePhase_dq because
fast electrical transients and asymmetries are
neglected. For more precise simulation of
power grid, you can use the SPOT from
PowerSystems supporting AC 3 phase.
West Lab
69
Thank	you	for	your	attention
West Lab
70
Converter
(DC/AC)
Energy
Consumer
Frequency
Data
PowerPlant
West Lab
71
HydroDispatch:
HydroDispatch[1] = hydroBase
HydroDispatch[2] = hydroDaily
HydroDispatch[3] = controlHydro
plantDispatch:
plantDispatch[1] = plantSchedule
plantDispatch[2] = secondaryControl
plantDispatch[3] = primaryControl
𝜃 = 𝜔 $ 2𝜋
LoadDispatcher
West Lab
72
PowerPlant
plantDispatch:
plantDispatch[1] = plantSchedule = fuel.u1
plantDispatch[2] = secondaryControl = add.u1
plantDispatch[3] = primaryControl
West Lab
73
HydroPlant
HydroDispatch:
HydroDispatch[1] = hydroBase = riverControl.u
HydroDispatch[2] = hydroDaily = add.u2
HydroDispatch[3] = controlHydro
West Lab
74
WindFarm
Wind Data
West Lab
75
City
West Lab
Open Modelica Library
76
• Simulation Result
city
windFarm
hydroPlant
powerPlant
West Lab
IPSL
77

More Related Content

PDF
SREチームとしてSREしてみた話
PPTX
nishit ambule special purpose machines presentation
PDF
Basics of Sheetmetal operations
PPTX
Industrial training presentation (mechanical engineering)
PPTX
インフラエンジニアに送るVSCode 入門
PDF
(Unityよくわかってない人のための)なんとなくわかるかもしれないAssetBundle
PPTX
Sheet metal design.pptx
SREチームとしてSREしてみた話
nishit ambule special purpose machines presentation
Basics of Sheetmetal operations
Industrial training presentation (mechanical engineering)
インフラエンジニアに送るVSCode 入門
(Unityよくわかってない人のための)なんとなくわかるかもしれないAssetBundle
Sheet metal design.pptx

What's hot (20)

PDF
Redmineチューニングの実際と限界(旧資料) - Redmine performance tuning(old), See Below.
PDF
目grep入門 +解説
PDF
挫折しないRedmine
PPTX
GD&T - PPT
PPTX
Redmine + Lychee導入のアンチパターン
PPTX
java.lang.OutOfMemoryError #渋谷java
PPTX
PRESS TOOL OPERATIONS
PDF
その ionice、ほんとに効いてますか?
PDF
人生がときめくAPIテスト自動化 with Karate
PPT
TURNING BY NIKHIL PAKWANNE
PPTX
Ppt on catia
PDF
うちのRedmineの使い方(2)
PDF
Jbatch実践入門 #jdt2015
PDF
Cnc milling programs
PDF
Jig, fixture & guages theory
PDF
Uvm cookbook-systemverilog-guidelines-verification-academy
PDF
うちのRedmineの使い方
PDF
hooks riverpod + state notifier + freezed でのドメイン駆動設計
PPTX
PRINCIPLE OF LATHE MACHINE
PPTX
GitLabを16万8千光年ワープさせた話(改)
Redmineチューニングの実際と限界(旧資料) - Redmine performance tuning(old), See Below.
目grep入門 +解説
挫折しないRedmine
GD&T - PPT
Redmine + Lychee導入のアンチパターン
java.lang.OutOfMemoryError #渋谷java
PRESS TOOL OPERATIONS
その ionice、ほんとに効いてますか?
人生がときめくAPIテスト自動化 with Karate
TURNING BY NIKHIL PAKWANNE
Ppt on catia
うちのRedmineの使い方(2)
Jbatch実践入門 #jdt2015
Cnc milling programs
Jig, fixture & guages theory
Uvm cookbook-systemverilog-guidelines-verification-academy
うちのRedmineの使い方
hooks riverpod + state notifier + freezed でのドメイン駆動設計
PRINCIPLE OF LATHE MACHINE
GitLabを16万8千光年ワープさせた話(改)
Ad

Similar to Modelica Tutorial with PowerSystems: A tutorial for Modelica simulation (20)

PDF
Electrical Circuit Lab
DOCX
ECET 405 Success Begins/Newtonhelp.com
DOCX
ECET 365 Success Begins /newtonhelp.com 
DOCX
ECET 365 Success Begins/Newtonhelp.com
PDF
Ecet 365 Enhance teaching / snaptutorial.com
DOCX
ECET 365 Exceptional Education / snaptutorial.com
DOC
Ecet 365 Education Redefined - snaptutorial.com
PDF
DOCX
ECET 402 Entire Course NEW
PPTX
LTspice_lecture electronic circuit Modeling.pptx
PDF
Edc lab 4 - to implement a half wave rectifier using diode
PDF
OPAL-RT HYPERSIM Features applied for Relay Testing
PPTX
L3-.pptx
PPTX
Hands-on-OpenIPSL.org using OpenModelica!
PDF
Proposal and implementation of a novel perturb and observe algorithm using em...
PPTX
How to use SIMULINK.pptx
PPTX
SPICE LEVEL I/LEVEL II/LEVEL III AND BSIM MODELS
PPT
Implementation of quantum gates using verilog
PDF
RT15 Berkeley | Power HIL Simulator (SimP) A prototype to develop a high band...
PDF
PyParis2017 / Circuit simulation using Python, by Fabrice Salvaire
Electrical Circuit Lab
ECET 405 Success Begins/Newtonhelp.com
ECET 365 Success Begins /newtonhelp.com 
ECET 365 Success Begins/Newtonhelp.com
Ecet 365 Enhance teaching / snaptutorial.com
ECET 365 Exceptional Education / snaptutorial.com
Ecet 365 Education Redefined - snaptutorial.com
ECET 402 Entire Course NEW
LTspice_lecture electronic circuit Modeling.pptx
Edc lab 4 - to implement a half wave rectifier using diode
OPAL-RT HYPERSIM Features applied for Relay Testing
L3-.pptx
Hands-on-OpenIPSL.org using OpenModelica!
Proposal and implementation of a novel perturb and observe algorithm using em...
How to use SIMULINK.pptx
SPICE LEVEL I/LEVEL II/LEVEL III AND BSIM MODELS
Implementation of quantum gates using verilog
RT15 Berkeley | Power HIL Simulator (SimP) A prototype to develop a high band...
PyParis2017 / Circuit simulation using Python, by Fabrice Salvaire
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Spectroscopy.pptx food analysis technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
sap open course for s4hana steps from ECC to s4
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.

Modelica Tutorial with PowerSystems: A tutorial for Modelica simulation