-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Morpho-lang/release-053
Updates for 0.5.3
- Loading branch information
Showing
19 changed files
with
219 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
\hypertarget{complex}{% | ||
\section{Complex}\label{complex}} | ||
|
||
Morpho provides complex numbers. The keyword \texttt{im} is used to | ||
denote the imaginary part of a complex number: | ||
|
||
\begin{lstlisting} | ||
var a=1+5im | ||
print a*a | ||
\end{lstlisting} | ||
|
||
Print values on the unit circle in the complex plane: | ||
|
||
\begin{lstlisting} | ||
import constants | ||
for (phi in 0..Pi:Pi/5) print exp(im*phi) | ||
\end{lstlisting} | ||
|
||
Get the real and imaginary parts of a complex number: | ||
|
||
\begin{lstlisting} | ||
print real(a) | ||
print imag(a) | ||
\end{lstlisting} | ||
|
||
or alternatively: | ||
|
||
\begin{lstlisting} | ||
print a.real() | ||
print a.imag() | ||
\end{lstlisting} | ||
|
||
\hypertarget{angle}{% | ||
\section{Angle}\label{angle}} | ||
|
||
Returns the angle \texttt{phi} associated with the polar representation | ||
of a complex number \texttt{r*exp(im*phi)}: | ||
|
||
\begin{lstlisting} | ||
print z.angle() | ||
\end{lstlisting} | ||
|
||
\hypertarget{conj}{% | ||
\section{Conj}\label{conj}} | ||
|
||
Returns the complex conjugate of a number: | ||
|
||
\begin{lstlisting} | ||
print z.conj() | ||
\end{lstlisting} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
\hypertarget{meshslice}{% | ||
\section{Meshslice}\label{meshslice}} | ||
|
||
The \texttt{meshslice} module is used to slice a \texttt{Mesh} object | ||
along a given plane, yielding a new \texttt{Mesh} object of lower | ||
dimensionality. You can also use \texttt{meshslice} to project | ||
\texttt{Field} objects onto the new mesh. | ||
|
||
To use the module, begin by importing it: | ||
|
||
\begin{lstlisting} | ||
import meshslice | ||
\end{lstlisting} | ||
|
||
Then construct a \texttt{MeshSlicer} object, passing the mesh you want | ||
to slice in the constructor: | ||
|
||
\begin{lstlisting} | ||
var slice = MeshSlicer(mesh) | ||
\end{lstlisting} | ||
|
||
You then perform a slice by calling the \texttt{slice} method, passing | ||
the plane you want to slice through. This method returns a new | ||
\texttt{Mesh} object comprising the slice. A plane is defined by a point | ||
that lies on the plane \texttt{pt} and a direction normal to the plan | ||
\texttt{dirn}: | ||
|
||
\begin{lstlisting} | ||
var slc = slice.slice(pt, dirn) | ||
\end{lstlisting} | ||
|
||
Having performed a slice, you can then project any associated | ||
\texttt{Field} objects onto the sliced mesh by calling the | ||
\texttt{slicefield} method: | ||
|
||
\begin{lstlisting} | ||
var phi = Field(mesh, fn (x,y,z) x+y+z) | ||
var sphi = slice.slicefield(phi) | ||
\end{lstlisting} | ||
|
||
The new field returned by \texttt{slicefield} lives on the sliced mesh. | ||
You can slice any number of fields. | ||
|
||
You can perform multiple slices with the same \texttt{MeshSlicer} simply | ||
by calling \texttt{slice} again with a different plane. | ||
|
||
\hypertarget{slcempty}{% | ||
\section{SlcEmpty}\label{slcempty}} | ||
|
||
This error occurs if you try to use \texttt{slicefield} on a | ||
\texttt{MeshSlicer} without having performed a slice. For example: | ||
|
||
\begin{lstlisting} | ||
var slice = MeshSlicer(mesh) | ||
slice.slicefield(phi) // Throws SlcEmpty | ||
slice.slice([0,0,0],[1,0,0]) | ||
\end{lstlisting} | ||
|
||
To fix, call \texttt{slice} before \texttt{slicefield}: | ||
|
||
\begin{lstlisting} | ||
var slice = MeshSlicer(mesh) | ||
slice.slice([0,0,0],[1,0,0]) | ||
slice.slicefield(phi) // Now slices correctly | ||
\end{lstlisting} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ Morpho | |
optimize | ||
plot | ||
povray | ||
vtk | ||
|
||
.. toctree:: | ||
:caption: Error messages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters