[PYTHON] Try FEniCS on Windows!

Introduction

The world of CAE is also increasingly available in Open Source. This time, [Finite Element Method](https://ja.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E8%A6%81%E7%B4%A0%E6%B3% Try FEniCS, which is one of the Open Source of 95) and has a Python interface.

What to do in this article

Most of CAE's Open Source is in a Linux environment, but this time I will run it on Windows 10 (using WSL) and run the example of the FEniCS tutorial.

environment

Windows 10 home WSL Ubuntu Anaconda (installed on Python 3.7.6 WSL) Chrome 80.0.3987.132

WSL environment construction

Since FEniCS requires a Linux environment, build a Linux environment with WSL. Refer to other sites for the construction method. Linux has Unbuntu.

Install Anaconda on WSL

Install the Linux version of Anaconda 3 downloaded from Anaconda in a suitable location. Install it in your home directory without thinking.

WSL


$sh Anaconda3-2020.02-Linux-x86_64.sh

Install FEniCS

According to the FEniCS Download Site, you can install the FEniCS library with conda. I tried installing with pip, but imoprt fenics got an import error, so if you don't want to get stuck, you may want to install with conda. (Since the fenics module only imports the dolfin of the main library, I feel that it is not important to be able to import fenics. However, in the world of Open Source CAE, if you do something different from the official one, you will get lost on the road.)

WSL


$conda install -c conda-forge feincs

Launch Jupyter Lab from WSL and display it on the browser on the Windows side

You can use FEniCS by performing calculations on WSL, saving the result file in a Windows folder, reading it on the Windows side, and post-processing it. However, since it is executed in the Python environment, I would like to use JupyterLab (Jupyter Notebook is also acceptable) to execute calculation execution and post processing in the same environment. Therefore, first install JupyterLab with WSL.

WSL


$conda install jupyterlab

After installation, launch Jupyter Lab on WSL.

WSL


$jupyter lab

If Xming etc. is not installed and executed on the Windows side, the GUI cannot be started on the Windows side, so nothing will be started. You can insert Xming, but if you enter http: // localhost: 8888 /? Token = xxx (xxx is the token at that time) displayed on WSL into the browser on the Windows side, it will start up from WSL. Jupyter Lab is displayed.

boot.png

Try FEniCS on Jupyter Lab

Copy and execute Example ft03_heat.py on the FEniCS site. If you execute it as it is, an error will occur.

error.png

According to this site, the function name seems to be old, so get_local is recommended. Rewrite array to get_local and execute. However, even if I fix it, I get an error.

error2.png

Looking at the error, it seems that there is no interactive. Examine, interactive () now plt.show () It is said that it has been changed. It should be described in DOLFIN documentation which is the execution body of FEniCS. Are you saying? However, since the figure is already displayed, delete it and execute it.

success.png

Obviously, you can complete the execution without any errors. Please note that some Official Examples have not been modified.

Recommended Posts

Try FEniCS on Windows!
Try Poerty on Windows
Try using OpenCV on Windows
Python on Windows
Try using Bash on Windows 10 2 (TensorFlow installation)
Pylint on Windows Atom
Linux (WSL) on Windows
Use pyvenv on Windows
Anaconda on Windows Terminal
Install Anaconda on Windows 10
Install python on windows
Install pycuda on Windows10
Build TensorFlow on Windows
Build XGBoost on Windows
Install pygraphviz on Windows 10
Use Ansible on Windows
Try NeosVR on Linux
Install Chainer 1.5.0 on Windows
Use QuTiP on Windows
Use pip on Windows
Try deepdream on Mac
Try using E-Cell 4 on Windows 7 or Mac OS X
Install Numpy on virtualenv on Windows
Run Jupyter on Ubuntu on Windows
Run Openpose on Python (Windows)
Install watchdog on Windows + Python 3.3
Install Win-Kex (kali-linux) on Windows 10.
Try StyleGAN on Google Colaboratory
Before trying Veriloggen on Windows
Install cvxpy on windows, Anaconda
Prepare Chainer environment on Windows
F2py on Miniconda for Windows
Make Cython available on Windows.
Fastest Python installation on Windows
Operate ubuntu on VScode (windows10)
Build Python environment on Windows
Try "100 knocks on data science" ①
Django environment development on Windows 10
Build python environment on windows
Set up Polyglot on Windows
Linux on Windows -1-: debian introduction
I ran python on windows
[Tensorflow] Tensorflow environment construction on Windows 10
Notes on installing Anaconda 3 on Windows
[Python] [Chainer] [Windows] Install Chainer on Windows
Use Python on Windows (PyCharm)
Run Jupyter Notebook on windows
Use Linux on Windows 10 (WSL2)
Blogging with Pelican on Windows
Build an environment on windows10 where you can try MXNet
Python environment construction memo on Windows 10
Remove ubuntu installed on Windows 10 machine
Try running tensorflow on Docker + anaconda
Try using Pillow on iPython (Part 1)
Pip install --ugrade pip fails on Windows
Anaconda python environment construction on Windows 10
How to use Dataiku on Windows
Drawing graphs on Windows10 + Julia + PyPlot
Try installing OpenAM on Amazon Linux
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows