Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for 0.5.3 #134

Merged
merged 2 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified manual/manual.pdf
Binary file not shown.
50 changes: 50 additions & 0 deletions manual/src/Reference/complex.tex
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}
52 changes: 40 additions & 12 deletions manual/src/Reference/functionals.tex
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ \section{GaussCurvature}\label{gausscurvature}}
The \texttt{GaussCurvature} computes the integrated gaussian curvature
over a surface.

Note that for surfaces with a boundary, the integrand is correct only
for the interior points. To compute the geodesic curvature of the
boundary in that case, you can set the optional flag \texttt{geodesic}
to \texttt{true} and compute the total on the boundary selection. Here
is an example for a 2D disk mesh.

\begin{lstlisting}
var mesh = Mesh("disk.mesh")
mesh.addgrade(1)

var whole = Selection(mesh, fn(x,y,z) true)
var bnd = Selection(mesh, boundary=true)
var interior = whole.difference(bnd)

var gauss = GaussCurvature()
print gauss.total(mesh, selection=interior) // expect: 0
gauss.geodesic = true
print gauss.total(mesh, selection=bnd) // expect: 2*Pi
\end{lstlisting}

\hypertarget{gradsq}{%
\section{GradSq}\label{gradsq}}

Expand Down Expand Up @@ -274,27 +294,35 @@ \section{AreaIntegral}\label{areaintegral}}
integrand function in the order you supply them to
\texttt{AreaIntegrand}.

\hypertarget{floryhuggins}{%
\section{FloryHuggins}\label{floryhuggins}}
\hypertarget{hydrogel}{%
\section{Hydrogel}\label{hydrogel}}

The \texttt{FloryHuggins} functional computes the Flory-Huggins mixing
energy over an element:
The \texttt{Hydrogel} functional computes the Flory-Rehner energy over
an element:

\begin{lstlisting}
a*phi*log(phi) + b*(1-phi)+log(1-phi) + c*phi*(1-phi)
(a*phi*log(phi) + b*(1-phi)+log(1-phi) + c*phi*(1-phi))*V +
d*(log(phiref/phi)/3 - (phiref/phi)^(2/3) + 1)*V0
\end{lstlisting}

where a, b and c are parameters you can supply. The value of phi is
calculated from a reference mesh that you provide on initializing the
Functional:
The first three terms come from the Flory-Huggins mixing energy, whereas
the fourth term proportional to d comes from the Flory-Rehner elastic
energy.

The value of phi is calculated from a reference mesh that you provide on
initializing the Functional:

\begin{lstlisting}
var lfh = FloryHuggins(mref)
var lfh = Hydrogel(mref)
\end{lstlisting}

Manually set the coefficients and grade to operate on:
Here, a, b, c, d and phiref are parameters you can supply (they are
\texttt{nil} by default), V is the current volume and V0 is the
reference volume of a given element. You also need to supply the initial
value of phi, labeled as phi0, which is assumed to be the same for all
the elements. Manually set the coefficients and grade to operate on:

\begin{lstlisting}
lfh.a = 1; lfh.b = 1; lfh.c = 1;
lfh.grade = 2
lfh.a = 1; lfh.b = 1; lfh.c = 1; lfh.d = 1;
lfh.grade = 2, lfh.phi0 = 0.5, lfh.phiref = 0.1
\end{lstlisting}
65 changes: 65 additions & 0 deletions manual/src/Reference/meshslice.tex
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}
45 changes: 43 additions & 2 deletions manual/src/Reference/meshtools.tex
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ \section{MeshBuilder}\label{meshbuilder}}
\end{lstlisting}

You can then add vertices, edges, etc. one by one using
\texttt{addvertex}, \texttt{addedge} and \texttt{addtriangle}. Each of
these returns an element id:
\texttt{addvertex}, \texttt{addedge}, \texttt{addface} and
\texttt{addelement}. Each of these returns an element id:

\begin{lstlisting}
var id1=build.addvertex(Matrix([0,0,0]))
Expand All @@ -137,6 +137,47 @@ \section{MeshBuilder}\label{meshbuilder}}
var m = build.build()
\end{lstlisting}

You can specify the dimension of the \texttt{Mesh} explicitly when
initializing the \texttt{MeshBuilder}:

\begin{lstlisting}
var mb = MeshBuilder(dimension=2)
\end{lstlisting}

or implicitly when adding the first vertex:

\begin{lstlisting}
var mb = MeshBuilder()
mb.addvertex([0,1]) // A 2D mesh
\end{lstlisting}

\hypertarget{mshblddimincnstnt}{%
\section{MshBldDimIncnstnt}\label{mshblddimincnstnt}}

This error is produced if you try to add a vertex that is inconsistent
with the mesh dimension, e.g.~

\begin{lstlisting}
var mb = MeshBuilder(dimension=2)
mb.addvertex([1,0,0]) // Throws an error!
\end{lstlisting}

To fix this ensure all vertices have the correct dimension.

\hypertarget{mshblddimunknwn}{%
\section{MshBldDimUnknwn}\label{mshblddimunknwn}}

This error is produced if you try to add an element to a
\texttt{MeshBuilder} object but haven't yet specified the dimension (at
initialization) or by adding a vertex.

\begin{lstlisting}
var mb = MeshBuiler()
mb.addedge([0,1]) // No vertices have been added
\end{lstlisting}

To fix this add the vertices first.

\hypertarget{meshrefiner}{%
\section{MeshRefiner}\label{meshrefiner}}

Expand Down
2 changes: 1 addition & 1 deletion manual/src/Reference/plot.tex
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ \section{Plotfield}\label{plotfield}}
\texttt{default} - Color \texttt{Mesh} elements by the corresponding
value of the \texttt{Field}.
\item
\texttt{interpolated} - Interpolate \texttt{Field} quantities onto
\texttt{interpolate} - Interpolate \texttt{Field} quantities onto
higher elements.
\end{itemize}
Binary file modified manual/src/Tutorial/0ExampleMesh/meshgrade0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/0ExampleMesh/meshgrade1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/0ExampleMesh/meshgrade2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/1Mesh/mesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/2Visualize/out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/2Visualize/selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/3Refine/out1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/3Refine/out2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified manual/src/Tutorial/3Refine/out3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion manual/src/manual.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ figs-within-sections
\begin_inset Newline newline
\end_inset

Version 0.5.2
Version 0.5.3
\end_layout

\begin_layout Standard
Expand Down Expand Up @@ -4178,6 +4178,16 @@ filename "Reference/array.tex"
\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset include
LatexCommand input
filename "Reference/complex.tex"

\end_inset


\end_layout

\begin_layout Standard
Expand Down
6 changes: 6 additions & 0 deletions morpho5/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
* @brief Define constants that choose how Morpho is built
*/

/* **********************************************************************
* Version
* ********************************************************************** */

#define MORPHO_VERSIONSTRING "0.5.3"

/* **********************************************************************
* Paths and file system
* ********************************************************************** */
Expand Down
1 change: 1 addition & 0 deletions morpho5/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Morpho
optimize
plot
povray
vtk

.. toctree::
:caption: Error messages
Expand Down
4 changes: 2 additions & 2 deletions morpho5/interface/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ void cli_help (lineditor *edit, char *query, error *err, bool avail) {
void cli(clioptions opt) {
#ifdef MORPHO_LONG_BANNER
printf(BLU " ___ ___ \n" RESET);
printf(BLU "(" CYN " @ " GRY"\\Y/" CYN " @ " BLU ") " RESET " | morpho 0.5.2 | \U0001F44B Type 'help' or '?' for help\n");
printf(BLU "(" CYN " @ " GRY"\\Y/" CYN " @ " BLU ") " RESET " | morpho " MORPHO_VERSIONSTRING " | \U0001F44B Type 'help' or '?' for help\n");
printf(BLU " \\" CYN"__" GRY"+|+" CYN"__" BLU"/ " RESET " | Documentation: https://morpho-lang.readthedocs.io/en/latest/ \n");
printf(BLU" {" CYN"_" BLU "/ \\" CYN "_" BLU"} " RESET " | Code: https://github.com/Morpho-lang/morpho \n\n");
#else
printf("\U0001F98B morpho 0.5.2 | \U0001F44B Type 'help' or '?' for help\n");
printf("\U0001F98B morpho " MORPHO_VERSIONSTRING " | \U0001F44B Type 'help' or '?' for help\n");
#endif
// Original ASCII art source - https://www.asciiart.eu/animals/insects/butterflies
cli_file=NULL;
Expand Down