The Morpho language 🦋. Morpho is a small embeddable language for scientific computing applications.
We're pleased to announce Morpho 0.6.0, which represents a great deal of behind-the-scenes work to ready the Morpho codebase for future developments. See our Roadmap document for more details.
Rather than the previous monolithic strucutre, the Morpho codebase has been divided into a shared library ("libmorpho") and a terminal application ("morpho-cli"). This means that Morpho can easily be embedded in other applications, and improves maintainability as these components can be updated separately. Morphoview has been migrated to a separate repository.
Functionals like LineIntegral
, AreaIntegral
and VolumeIntegral
can now make use of a greatly improved quadrature routine. This will become the default in future versions of Morpho. Particularly in 3D, the new routine offers significantly improved performance, and can be extended in future. To use the new quadrature routine simply set the method
optional argument:
var a = AreaIntegral(integrandfn, method = {})
The method Dictionary can specifically request particular quadrature rules or orders; more information will be in the dev guide.
You can now use the import
keyword with a new keyword, as
, to import the contents of a module into a given namespace:
import color as col
print col.Red
This helps Morpho programs avoid library conflicts and improves modularization.
Morpho now supports Tuples, an ordered immutable collection. The syntax is similar to Python:
var t = (0,1,2,3)
Tuples act much like Lists, but can be used as keys in a Dictionary.
Morpho now provides a JSON
class which supports import and output using the JavaScript Object Notation (JSON) format, widely used for data interchange.
var a = JSON.parse("[1,2,3]")
print a
format
method on the Int
and Float
classes.Many previously un- or under-documented features have now been added to the interactive help. If you notice something that isn't well documented, please alert us via the issue tracker in Github.
Prerelease for v0.6.0.
0.5.7 is the final release in the 0.5 series. This release contains a number of improvements and bugfixes:
We have updated the installation instructions for Windows with this release to work with either WSL1 or WSL2.
You can now compute the local gradient of a field using the grad() function within the integrand supplied to AreaIntegral and VolumeIntegral. This significantly enhances the number of models morpho can handle.
System.print(), System.readline() and System.sleep() methods added.
System.clock() now reports wall time (useful for testing the effect of parallelization)
System.arguments() provides access to the command line options morpho was run with.
New Matrix.roll() and List.roll() methods shift the contents of a List or Matrix respectively.
Field.linearize() provides access to the underlying Matrix store.
IdentityMatrix() constructor function.
Debugger now supports printing of global variables and object properties.
Fix issues with compilation on some platforms.
Experimental support for accessing integrand values for individual elements on some functionals.
Numerous minor bugfixes.
Morpho now supports parallelized force and energy calculations, which can lead to significant speedups for some programs. To use these, run morpho with -w flag and supply the number of worker threads to use:
morpho5 -w4 program.morpho
Further features for parallel programming will appear in future releases.
The morpho runtime can now look for resource files---help files, morpho files, etc.---in multiple places. The default location is now configurable at installation, and also via a .morphopackages file stored in the user home directory. This enables morpho modules to live in their own git repository, together with resource files, and should make it easier for users to contribute to morpho. More details are in the dev guide.
It's now possible to extend morpho through dynamic libraries written in C and linked at runtime. From the user's perspective, these work just like modules using the import
keyword.
We continue to improve the manual, and now include a chapter on visualization. The developer guide has also been updated.
Morpho 0.5.6 includes:
Morpho now supports parallelized force and energy calculations, which can lead to significant speedups for some programs. To use these, run morpho with -w flag and supply the number of worker threads to use:
morpho5 -w4 program.morpho
Further features for parallel programming will appear in future releases.
The morpho runtime can now look for resource files---help files, morpho files, etc.---in multiple places. The default location is now configurable at installation, and also via a .morphopackages file stored in the user home directory. This enables morpho modules to live in their own git repository, together with resource files, and should make it easier for users to contribute to morpho. More details are in the dev guide.
It's now possible to extend morpho through dynamic libraries written in C and linked at runtime. From the user's perspective, these work just like modules using the import
keyword.
We have added two new chapters to the manual, one on working with Meshes and the other describing the examples in detail. Additional chapters to follow. We've also improved the formatting of the manual, and a number of previously undocumented features are now documented in the manual and in the interactive help. A first draft of a developers guide, to be expanded on further, is also included.
Morpho now provides a profiler and a rewritten debugger. To use these, run with -profile or -debug respectively. Upon completion, the profiler will produce a report of the fraction of program execution time spent in each morpho function, allowing the programmer to identify optimization targets. We've used this tool to significantly improve a number of morpho components.
You can now create a class from multiple other classes (called a mixin) using the new with
keyword:
class Foo is Boo with Hoo, Moo { ... }
Boo is the superclass of Foo, but methods defined in Hoo and Moo are copied into Foo before Foo's methods are defined. This enables greater modularity and facilitates code reuse.
Its now possible to convert Sparse matrices to dense matrices and vice-versa by passing them to the relevant constructor function, e.g.
var a = Sparse([[0,0,1],[1,1,1]])
var b = Matrix(a)
You can assemble matrices in block form using other matrices:
var c = Matrix([[a,0],[0,a]])
You can compute the eigenvalues and eigenvectors of a matrix with the new eigenvalues() and eigensystem() methods.
Preliminary work for numerical hessians is in place.
graphics
, plot
and povray
modules have been updated to support this, including new ScaleBar
and plotmeshlabels
.MeshPruner
class to coarsen meshes. 3D refinement now supported. Improved refinement of Selections.System
class will become a repository for new system-related functionality.The meshtools
module has been extensively revised with many new features:
MeshPruner
class added that enables coarsening of meshes, analogous to MeshRefiner
.MeshRefiner
and MeshMerge
to prevent duplicate elements being generated in some circumstances.The morphoview
application now supports text rendering. A number of modules have been updated to take advantage of this:
plot
now provides ScaleBar
objects that are useful for plotfield
, as well as plotmeshlabels
to label a mesh with element ids.graphics
now provides a Text
class for textual elements, and has some performance improvements.color
now provides a number of new ColorMap
s: ViridisMap
, InfernoMap
, MagmaMap
and PlasmaMap
, all of which are more friendly for people with color vision deficiency.You can now create functions that accept a variable number of parameters. Arguments passed to a function can be accessed as a List
.
fn func(x, ...v) {
for (a in v) print a
}
Other improvements:
VolumeIntegral
module to complement AreaIntegral
and LineIntegral
.System
class to enable you to get platform information.povray
module.plot
module.morphoview
by right click and dragging or using alt-arrow keys.This version includes the following highlights:
Full Changelog: https://github.com/Morpho-lang/morpho/compare/v0.5.2...v0.5.3
meshgen
module to create meshes in 2D and 3D.delaunay
module to create Delaunay triangulations in arbitrary dimensions.vtk
module to load and save meshes and fields in VTK legacy format.List
, Array
and Matrix
slices (e.g. a[0..5]
means elements 0 to 5 of a list)