Installing Fenics on Windows

I don’t know what to tell you aside of V=U\times T, therefore U,T=split(V) and likewise any Function u on U (including TrialFunctions and TestFunctions) may be split the same way with w,theta=split(u). It seems very natural to me.

For more details, look into UFL documentation.

About that last point for figure saving, I don’t think you will need run_line_magic (that was the whole point of the proposed workaround), but I can only encourage you to try.

You do not need run_line_magic.

The tutorial appears to have been developed in a Jupyter notebook, and that command appears to be an artifact from converting the notebook to a Python script. The line %matplotlib notebook in the tutorial is a Jupyter “magic” that tells matplotlib to use the “nbAgg” backend, which creates interactive figures that appear inline in the notebook. (See here and here for more information.)

Thank you it is working. How can I add the effect of gravity in this ?

I tried to do the second one, but I got an error

from dolfin import *
from ufl import Jacobian, diag
from plotting import plot


When I search for plotting module python it direct to matplotlib that I already have. Is there another module that need to be installed ?

It looks like this is the plotting module you should install: plotting · PyPI.

spyder and paraview are available on Ubuntu, so you’ll be certainly able to install them inside your linux subsystem. Within linux they run as X11 applications, so getting X11 to run from your virtual Ubuntu machine inside Windows will be the challenge. Some configuration will be needed to communicate the X11 display between the linux subsystem and the windows host system. I’m not sure what needs to be done exactly to make that work, or whether it’s difficult or easy. There’s likely to be some discussion about it somewhere. It might need installation of an X server on Windows, which would handle the display of the applications.

For the record, I had to do that a while ago, and it works well.
Here is what I did, if anyone needs to do the same:

  • Install VcXsrv on windows, and run the executable
  • Check the ‘disable access control’ checkbox in the VcXsrv config
  • Export the X11 server address to the DISPLAY variable in the WSL session. To do so, add the following line to ~/.bashrc (or whatever your shell is)
    export DISPLAY=$(grep nameserver /etc/resolv.conf | awk '{print $2}'):0.0

That should be enough to enable launching X11 apps from WSL.

2 Likes

Hello,

I am still working on this code and I need to add the effect of gravity.
I supposed that the beam is standing up, so I just want to do a modification of the N0 in the kg_form.
I did this:

rho = Constant(7500.)
gravity = Constant(9.81)

Weight = gravitythickwidthrhodx

N0 = Constant(1e-3)

Comp = N0 + Weight

kg_form = Comp*dot(grad(w_), grad(dw))*dx
KG = PETScMatrix()
assemble(kg_form, tensor=KG)
for bci in bc:
bci.zero(KG)

But I am missing an itegration domain. How can I add this domain.

And How can add gravity if the beam is horizontal? Can I just put U in 2D or should I create a new finite element to handle this new dimension

Weird the * disapeared

Here you go

Weight = gravity * thick * width * rho * dx

After sleeping on it, I’m a dumbass and I could just put L, the length instead of dx to avoid the integration. But still, I don’t understand why it won’t work. My biggest problem is to know how add gravity in the y-axis if the beam is in the x-axis with the code I gave previously. What is the optimal way.

1 Like

This is less of a FENICs than a physics question…

I recommend : Timoshenko–Ehrenfest beam theory - Wikipedia for a quick solution.

I’d say your fundamental equations look like :

\begin{cases} \frac{\text{d}^2}{\text{d}x^2}\left(EI\frac{\text{d}\varphi}{\text{d}x}\right)=\rho Ag\\ \frac{\text{d}w}{\text{d}x}=\varphi-\frac{1}{\kappa A G}\frac{\text{d}}{\text{d}x}\left(EI\frac{\text{d}\varphi}{\text{d}x}\right) \end{cases}

This gives the variational formulation :
k((w,\varphi),(\hat{w},\hat{\varphi}))=\int_0^L\left(\rho Ag\hat{\varphi}+EI\frac{\text{d}\hat{\varphi}}{\text{d}x}\frac{\text{d}^2\varphi}{\text{d}x^2}\right)\text{d}x+\int_0^L\left(\frac{\text{d}\hat{w}}{\text{d}x}w-\frac{\text{d}\hat{w}}{\text{d}x}\varphi+\frac{EI}{\kappa AG}\frac{\text{d}\hat{w}}{\text{d}x}\frac{\text{d}\varphi}{\text{d}x}\right)\text{d}x

That looks right to me, and should be easy to implement just like in Eulerian buckling of a beam — Numerical tours of continuum mechanics using FEniCS master documentation.

So am I correct to understand that Fenics/Dolfin (legacy) can only be installed on windows either through WSL or Docker?
I tried building from source but turns out dolfin requires petsc which as far as I understood can only be installed in cygwin.
Did I get any part of that wrong? Also how much slower would my code be if I do it through WSL or Docker?

Dolfin needs WSL or Docker. See for instance: https://arxiv.org/pdf/1608.07573.pdf which shows that there is very little performance penalty for using docker on workstations and hpc clusters.

1 Like

Ahhh I see. Thanks so much for the quick and informed reply.

On more question. In your experience, how do WSL and Docker compare in terms of raw performance?

See for instance: Ubuntu on Windows 10: Docker vs WSL - Ask Ubuntu

1 Like