# Nutils 'Hello world!' [closed]

Suppose I am completely new with the Python-based finite element package Nutils, what example code would help me to get started?

• Welcome to SciComp.SE! Note that pure software questions are off-topic on this site -- in particular, this site should not be used as the support forum for your finite element package! (You should look at the discussions about the "FEniCS experiment" on meta to see why.) Aug 22 '16 at 14:06
• It also looks quite suspicious if two of the lead developers of the software ask and answer their own questions in short succession... Possibly stackoverflow.com/documentation would be a better fit for what you seem to be trying to do here. You can also create your own Q&A forum, like FEniCS did: fenicsproject.org/qa Aug 22 '16 at 14:07
• Hi @ChristianClason, thanks for the feedback. Could you please comment on how this relates to the meta discussion "let's define our scope", which we consulted prior to selecting this platform and which states "Questions about how to use a particular piece of software, either at a user interface (graphical or not) or at a programming interface, are scicomp"? [emphasis mine] Aug 22 '16 at 18:43
• Indeed we did discuss whether SO would be the more appropriate platform, but given their hostility towards mathjax there would be no way to formulate any relevant question. And before we can use documentation (which does enable it) we need 500+ questions. With regard to your last comment: though it is of course true that we could have created our own Q&A forum, we assume that stackexchange provides their service with the objective that people make use of it. Aug 22 '16 at 18:45
• As I wrote, that was precisely what was tried with FEniCS, and the consensus was that this was not a good idea, for all parties involved. If you want to revisit this discussion (which you are welcome to do), you should ask a question on Meta (explaining the background of the project, what you hope to get out of it, and why concretely it would benefit this SE community) -- after all, I'm just a random guy on the internet and speak for no one except myself. Otherwise, the "on hold" status won't change unless the questions change. Aug 22 '16 at 21:35

The following fully functional script solves the Laplace problem for a scalar valued field $u$, such that for all test functions $v$: $$\int_\Omega ∇v·∇u = \int_{\Gamma_N} v f$$ where $\Omega$ is the unit square domain with a Neumann condition $f = 1$ on the right boundary $\Gamma_N$, a homogeneous Dirichlet condition $u = 0$ on the lower boundary, and natural boundary conditions on the remaining boundaries. The spaces are discretized using quadratic spline basis functions on an 8x8 computational grid.

from nutils import mesh, function, plot

# prepare domain, geometry, basis
domain, geom = mesh.rectilinear( [range(9),range(9)] )
basis = domain.basis( 'spline', degree=2 )

# construct matrix, right hand side, constraints
matrix = domain.integrate( basis['i,k'] * basis['j,k'], geometry=geom, ischeme='gauss2' )
rhs = domain.boundary['right'].integrate( basis, geometry=geom, ischeme='gauss2' )
con = domain.boundary['bottom'].project( 0, onto=basis, geometry=geom, ischeme='gauss2' )

# solve system
lhs = matrix.solve( rhs, constrain=con )
sol = basis.dot( lhs )

# plot solution
points, colors = domain.elem_eval( [geom, sol], ischeme='bezier9', separate=True )
with plot.PyPlot( 'solution' ) as plt:
plt.mesh( points, colors )
plt.colorbar()


Running this code generates the following graph of the solution:

## Where to go from here?

A more elaborate getting started document can be found here. Furthermore, the examples included in Nutils provide fully functional example code for a wide range of problems.