#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass report
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding auto
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_amsmath 1
\use_esint 1
\use_mhchem 0
\use_mathdots 0
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 3.5cm
\rightmargin 3.5cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language swedish
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Chapter
Modelica extension for PDE
\end_layout

\begin_layout Section
Requests on language extension and possible approaches
\end_layout

\begin_layout Section*
Space & coordinates
\end_layout

\begin_layout Subsubsection*
What should be specified
\end_layout

\begin_layout Itemize
Dimension of the problem (1,2 or 3D)
\end_layout

\begin_layout Itemize
?? Coordinates (cartesian, cylindrical, spherical ...) -- where this information
 will be used (if at all):
\end_layout

\begin_deeper
\begin_layout Itemize
in differential operators as grad, div, rot etc.
\end_layout

\begin_layout Itemize
in visualization of results
\end_layout

\begin_layout Itemize
?? in computation -- perhaps equations should be transformed and the calculation
 would be performed in cartesian coordinates
\end_layout

\end_deeper
\begin_layout Itemize
Names of independent (coordinate) variables (
\begin_inset Formula $x$
\end_inset

, 
\begin_inset Formula $y$
\end_inset

, 
\begin_inset Formula $z$
\end_inset

, 
\begin_inset Formula $r$
\end_inset

, 
\begin_inset Formula $\varphi$
\end_inset

, 
\begin_inset Formula $\theta$
\end_inset

...) 
\end_layout

\begin_layout Standard
Perhaps all these should be specified within the domain deffinition.
 
\begin_inset Newline newline
\end_inset

Dimension can be infered from number of return values of shape-function
 or different properities of the domain in other cases.
\begin_inset Newline newline
\end_inset

The base coordinates would be cartesian and they would be always implicitly
 defined in any domain.
 Besides that other coordinate systems could be defined also.
 
\begin_inset Newline newline
\end_inset

Names of independent variables in cartesian coordinates should be fixed
 
\emph on
x, (x,y), (x,y,z) 
\emph default
in 1D, 2D and 3D domains respectively.
\end_layout

\begin_layout Section*
Domain & boundary
\end_layout

\begin_layout Subsection*
What should be specified
\end_layout

\begin_layout Itemize
the domain where we perform the computation and where equations hold
\end_layout

\begin_layout Itemize
boundary and its subsets where particular boundary conditions hold
\end_layout

\begin_layout Itemize
normal vector of the boundary
\end_layout

\begin_layout Subsection*
Possible approaches
\end_layout

\begin_layout Description
Parametrization
\begin_inset space ~
\end_inset

of
\begin_inset space ~
\end_inset

the
\begin_inset space ~
\end_inset

domain with shape function and intervals -- from The Book (Principles of
 ...), section 8.5.2
\end_layout

\begin_layout Standard
Example from the book:
\end_layout

\begin_layout Standard
\align left

\family typewriter
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

model HeatCircular2D 
\end_layout

\begin_layout Plain Layout

	import DifferentialOperators2D.*;
\end_layout

\begin_layout Plain Layout

	parameter DomainCircular2DGrid omega;
\end_layout

\begin_layout Plain Layout

	FieldCircular2DGrid u(domain=omega, FieldValueType=SI.Temperature);
\end_layout

\begin_layout Plain Layout

equation 
\end_layout

\begin_layout Plain Layout

	der (u) = pder (u,D.x2)+ pder (u,D .
 y 2 )	in omega.interior;
\end_layout

\begin_layout Plain Layout

	nder(u) = 0		in omega.boundary; 
\end_layout

\begin_layout Plain Layout

end HeatCircular2D;
\end_layout

\begin_layout Plain Layout
\align left

\end_layout

\begin_layout Plain Layout

record DomainCircular2DGrid "Domain being a circular region"
\end_layout

\begin_layout Plain Layout

	parameter Real radius = 1;
\end_layout

\begin_layout Plain Layout

	parameter Integer nx = 100;
\end_layout

\begin_layout Plain Layout

	parameter Integer ny = 100;
\end_layout

\begin_layout Plain Layout

	replaceable function shapeFunc = circular2Dfunc "2D circular region";
\end_layout

\begin_layout Plain Layout

	DomainGe2D interior(shape=shapeFunc,interval={{O,radius},{O,l}},geom= ...
 );
\end_layout

\begin_layout Plain Layout

	DomainGe2D boundary (shape=shapeFunc, interval={{radius, radius), { 0,1}}
 ,geom=);
\end_layout

\begin_layout Plain Layout

	function shapeFunc = circular2Dfunc "Function spanning circular region";
\end_layout

\begin_layout Plain Layout

end DomainCircular2DGrid; 
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

function circular2Dfunc "Spanned circular region for v in interval 0..1" 
\end_layout

\begin_layout Plain Layout

	input Real r,v; 
\end_layout

\begin_layout Plain Layout

	output Real x,y; 
\end_layout

\begin_layout Plain Layout

algorithm 
\end_layout

\begin_layout Plain Layout

	x : = r*cos (2*PI*v);
\end_layout

\begin_layout Plain Layout

	y := r*sin(2*PI*v); 
\end_layout

\begin_layout Plain Layout

end circular2Dfunc; 
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

record FieldCircular2DGrid 
\end_layout

\begin_layout Plain Layout

	parameter DomainCircular2DGrid domain;
\end_layout

\begin_layout Plain Layout

	replaceable type FieldValueType = Real;
\end_layout

\begin_layout Plain Layout

	replaceable type FieldType = Real[domain.nx,domain.ny,domain.nz];
\end_layout

\begin_layout Plain Layout

	parameter FieldType start = zeros(domain.nx,domain.ny,domain.nz.);
\end_layout

\begin_layout Plain Layout

	FieldType Val;
\end_layout

\begin_layout Plain Layout

end FieldCircularZDGrid; 
\end_layout

\end_inset


\end_layout

\begin_layout Standard
And modified version, where all numerical stuff (grid, number of points
 -- this should be configured using simulation setup or annotations ) omitted,
 modified 
\family typewriter
pder
\family default
 operator, 
\family typewriter
Field
\family default
 as Modelica build-in type:
\end_layout

\begin_layout Standard
\align left
\begin_inset listings
inline false
status open

\begin_layout Plain Layout
\align left

model HeatCircular2D
\end_layout

\begin_layout Plain Layout
\align left

	parameter DomainCircular2D omega(radius=2);
\end_layout

\begin_layout Plain Layout
\align left

	field Real u(domain=omega, start = 0, FieldValueType=SI.Temperature);
\end_layout

\begin_layout Plain Layout
\align left

equation 
\end_layout

\begin_layout Plain Layout
\align left

	pder(u,time) = pder(u,x)+ pder(u,y) in omega.interior;
\end_layout

\begin_layout Plain Layout
\align left

	pder(u,omega.boundary.n) = 0   in omega.boundary; 
\end_layout

\begin_layout Plain Layout
\align left

end HeatCircular2D;
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

record DomainCircular2D
\end_layout

\begin_layout Plain Layout

	parameter Real radius = 1;
\end_layout

\begin_layout Plain Layout

    parameter Real cx = 0;
\end_layout

\begin_layout Plain Layout

	parameter Real cy = 0;
\end_layout

\begin_layout Plain Layout

	function shapeFunc
\end_layout

\begin_layout Plain Layout

		input Real r,v;
\end_layout

\begin_layout Plain Layout

		output Real x,y;
\end_layout

\begin_layout Plain Layout

	algorithm
\end_layout

\begin_layout Plain Layout

		x := cx + radius*r * cos(2 * C.pi * v);
\end_layout

\begin_layout Plain Layout

		y := cy + radius*r * sin(2 * C.pi * v);
\end_layout

\begin_layout Plain Layout

	end shapeFunc;
\end_layout

\begin_layout Plain Layout

	Region2D interior(shape = shapeFunc, interval = {{O,1},{O,1}});     	
\end_layout

\begin_layout Plain Layout

	Region1D boundary(shape = shapeFunc, interval = {{1,1},{0,1}});
\end_layout

\begin_layout Plain Layout

end DomainCircular2D; 
\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Description
Description
\begin_inset space ~
\end_inset

by
\begin_inset space ~
\end_inset

the
\begin_inset space ~
\end_inset

boundary Domain is defined by closed boundary curve, which may by composed
 of several connected curves.
 Needs new operator 
\emph on
interior
\emph default
 and type 
\emph on
Domain2d
\emph default
 (and 
\emph on
Domain1D
\emph default
 and 
\emph on
Domain3d
\emph default
).
 (similarly used in FlexPDE -- http://www.pdesolutions.com/.) 
\end_layout

\begin_layout Standard
\begin_inset CommandInset include
LatexCommand lstinputlisting
filename "boundaryRepresentation.mo"
lstparams "breaklines=true,captionpos=b"

\end_inset


\end_layout

\begin_layout Description
Constructive
\begin_inset space ~
\end_inset

solid
\begin_inset space ~
\end_inset

geometry used in Matlab PDE toolbox, http://en.wikipedia.org/wiki/Constructive_sol
id_geometry 
\end_layout

\begin_layout Standard
Domain is build from primitives (cuboids, cylinders, spheres, cones, user
 defined shapes ...) applying boolean operations 
\emph on
union
\emph default
, 
\emph on
intersection
\emph default
 and 
\emph on
difference.
\end_layout

\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename img/Csg_tree.png
	lyxscale 30
	width 40text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption

\begin_layout Plain Layout
constructive solid geometry
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
How to describe boundaries?
\end_layout

\begin_layout Description
Listing
\begin_inset space ~
\end_inset

of
\begin_inset space ~
\end_inset

points -- export from CAD
\end_layout

\begin_layout Description
Inequalities
\end_layout

\begin_layout Description
Boundary
\begin_inset space ~
\end_inset

representation
\begin_inset space ~
\end_inset

(BRep) (NETGEN, STEP)
\end_layout

\begin_layout Section*
Fields
\end_layout

\begin_layout Section*
Partial derivative
\end_layout

\begin_layout Standard

\family typewriter
\begin_inset Formula $\frac{\partial^{2}u}{\partial x\partial y}$
\end_inset

 ...
 pder(u,x,y)
\end_layout

\begin_layout Standard
directional derivative ...
 
\family typewriter
pder(u,omega.boundary.n)
\end_layout

\begin_layout Section*
Equations, boundary and initial conditions
\end_layout

\begin_layout Standard
Use the 
\emph on
in
\emph default
 operator to express where equations hold.
\end_layout

\begin_layout Section
New concepts and language elements
\end_layout

\begin_layout Description
domain
\begin_inset space ~
\end_inset

records
\begin_inset space ~
\end_inset

(or
\begin_inset space ~
\end_inset

class) 
\family typewriter
DomainLineSegment1D
\family default
, 
\family typewriter
DomainRectangle2D
\family default
, 
\family typewriter
DomainCircular2D
\family default
, 
\family typewriter
DomainBlock3D
\family default
 ...
 defined within 
\family typewriter
PDE
\family default
 package, user can define his/her own domain records.
 Domain record contains at least one region member 
\begin_inset Note Note
status open

\begin_layout Plain Layout
and coordinate defiinition?
\end_layout

\end_inset

.
 During translation is treated in different way than usual records.
\begin_inset Newline newline
\end_inset

Needs OMC modification.
\end_layout

\begin_layout Description
interval to define parameter interval for a shape-function.
 E.g.
 
\family typewriter
interval={{0,1},0}.
 
\family default
Used in domain records.
 (Previously called range.)
\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\begin_layout Description
shape
\begin_inset space ~
\end_inset

function one-to-one map of points in k-dimensional interval (usualy cartesian
 product of intervals) to points in n-dimensional domain and thus deffine
 a coordinate system in domain 
\begin_inset Note Note
status open

\begin_layout Plain Layout
How is the last sentence meant? (Should it be rather: 
\begin_inset Quotes sld
\end_inset

and thus determine shape of the domain in particular coordinates.
\begin_inset Quotes srd
\end_inset

)
\end_layout

\end_inset

.
 
\end_layout

\begin_layout Description
region
\begin_inset space ~
\end_inset

types
\begin_inset space ~
\end_inset

and
\begin_inset space ~
\end_inset

regions 
\family typewriter
Region0D
\family default
, 
\family typewriter
Region1D
\family default
, 
\family typewriter
Region2D
\family default
, 
\family typewriter
Region3D
\family default
 used in domain records to define interior, boundaries and othere regions
 where certain equations hold (e.g.
 connection of PDE and ODE).
 Two mandatory attributes are 
\family typewriter
shape
\family default
 and 
\family typewriter
interval
\family default
.
 E.g.
 
\family typewriter
Region2D left (shape = shapeFunc, interval = {0,{0,1}}).

\family default
 
\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\begin_layout Description
normal
\begin_inset space ~
\end_inset

vector implicitly defined for all N-1 dimensional regions in N dimensional
 domain.
 (e.g.
 
\family typewriter
omega.left.n
\family default
) Used in boundary condition equations.
 How to write domain and region independently - perhaps 
\family typewriter
region.n
\family default
?
\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\begin_layout Description
fields A variable whose value depends on space position, is called field.
 It is defined with keyword 
\family typewriter
field
\family default
.
 Field can be of any type.
 It can be defined also as a parameter.
 Field may be an array to represent vector field.
 Mandatory attribute is 
\family typewriter
domain
\family default
.
 Other attributes are same as for corresponding regular type (e.g.
 for 
\family typewriter
Real:
\family default
 
\family typewriter
start
\family default
, 
\family typewriter
fixed
\family default
, 
\family typewriter
nominal
\family default
, 
\family typewriter
min
\family default
, 
\family typewriter
max
\family default
, 
\family typewriter
unit
\family default
, 
\family typewriter
displayUnit
\family default
, 
\family typewriter
quantity
\family default
, 
\family typewriter
stateSelect
\family default
.
 (Not shure about 
\family typewriter
fixed
\family default
 and 
\family typewriter
stateSelect
\family default
.) Attribute 
\family typewriter
start
\family default
 can be assigned constant value or function of type (Real×Real×...)
\begin_inset Formula $\rightarrow$
\end_inset

typeOfField, number of arguments is same as dimension of fields domain.
 Start attribute can be treated as scalar or as array to assign initial
 values also to derivatives.
 E.g.
\family typewriter

\begin_inset Newline newline
\end_inset

field Real x(domain = omega, start[0] = xInit, start[1] = 0)
\begin_inset Newline newline
\end_inset


\family default
see 
\family typewriter

\begin_inset CommandInset ref
LatexCommand ref
reference "String-equation-(1D)"

\end_inset


\begin_inset Newline newline
\end_inset


\family default
New language element.
\end_layout

\begin_layout Description
operations
\begin_inset space ~
\end_inset

and
\begin_inset space ~
\end_inset

functions
\begin_inset space ~
\end_inset

on
\begin_inset space ~
\end_inset

fields All operators (= , :=, +, -, *, /, ^, <, <= ,> ,>= ,== , <>) and
 functions can be applied on fields.
 The result is also a field.
 If a binary operator or function of more arguments is applied on two (or
 more) fields, these fields must be defined within the same domain.
\begin_inset Newline newline
\end_inset

If some binary operator or function with more arguments is performed on
 field and regular variable (it means a variable that is not a field), the
 operation is performed as if the regular variable is field that is constant
 in space.
\end_layout

\begin_layout Description

\family typewriter
pder()
\family default

\begin_inset space ~
\end_inset

operator for partial and directional derivative of real field.
 Higher derivatives are allowed.
 E.g.
 
\family typewriter
pder(u,omega.x,omega.x,omega.y)
\family default
 means
\begin_inset Formula $\frac{\partial^{3}u}{\partial x^{2}y}$
\end_inset


\family typewriter
.

\family default
 Directional derivative: 
\family typewriter
pder(u,omega.left.n)
\family default
.
 Time derivative of field must be written also using 
\family typewriter
pder
\family default
 operator not 
\family typewriter
der.
\end_layout

\begin_layout Description

\family typewriter
in
\family default

\begin_inset space ~
\end_inset

operator to define where PDE, boundary conditions and other equations hold.
 On left is an equation on right is a region where the equation hold.
 
\begin_inset Newline newline
\end_inset

E.g.
 
\family typewriter
x=0
\begin_inset space \quad{}
\end_inset

in omega.left
\family default

\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\begin_layout Description

\family typewriter
dom
\family default

\begin_inset space ~
\end_inset

keyword stands for current domain specified with 
\family typewriter
in
\family default
 operator.
\begin_inset Newline newline
\end_inset


\family typewriter
pder(u,dom.x)=0
\begin_inset space ~
\end_inset

in
\begin_inset space ~
\end_inset

omega.interior;
\family default

\begin_inset Newline newline
\end_inset

is equivalent to
\begin_inset Newline newline
\end_inset


\family typewriter
pder(u,omega.x)=0
\begin_inset space ~
\end_inset

in
\begin_inset space ~
\end_inset

omega.interior;
\family default

\begin_inset Newline newline
\end_inset

Is useful to write equations domain independent.
\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\begin_layout Description

\family typewriter
region
\family default

\begin_inset space ~
\end_inset

keyword stands for current region specified with 
\family typewriter
in
\family default
 operator.
\begin_inset Newline newline
\end_inset


\family typewriter
v*region.n=0
\begin_inset space ~
\end_inset

in
\begin_inset space ~
\end_inset

omega.left + omega.right;
\family default

\begin_inset Newline newline
\end_inset

is equivalent to
\begin_inset Newline newline
\end_inset


\family typewriter
v*omega.left.n=0
\begin_inset space ~
\end_inset

in
\begin_inset space ~
\end_inset

omega.left;
\begin_inset space ~
\end_inset

v*omega.right.n=0
\begin_inset space ~
\end_inset

in
\begin_inset space ~
\end_inset

omega.right;
\family default

\begin_inset Newline newline
\end_inset

Is useful to get normal vector in domain independent equations and on anonymous
 regions.
\begin_inset Newline newline
\end_inset

New language element.
 Not shure if it will be needed.
\end_layout

\begin_layout Description
region
\begin_inset space ~
\end_inset

addition + operator can be used to add regions.
 Can be used in domain record to form a new region, e.g.
 
\family typewriter

\begin_inset Newline newline
\end_inset

boundaries = left + right;
\begin_inset Newline newline
\end_inset


\family default
or on right side of 
\family typewriter
in
\family default
 operator, e.g.
\family typewriter

\begin_inset Newline newline
\end_inset

x = 0
\begin_inset space \quad{}
\end_inset

in omega.left + omega.right;
\begin_inset Newline newline
\end_inset


\family default
New language element.
 Not shure if it will be needed.
\end_layout

\begin_layout Description
vector
\begin_inset space ~
\end_inset

differential
\begin_inset space ~
\end_inset

operators
\family typewriter
 grad,
\begin_inset space ~
\end_inset

div,
\begin_inset space ~
\end_inset

rot
\end_layout

\begin_layout Description

\family typewriter
Coordinate
\family default
 type to define new coordinates - design of concept unfinished.
 
\begin_inset Newline newline
\end_inset

New language element.
\end_layout

\end_body
\end_document
