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.
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.
Windows 10 home WSL Ubuntu Anaconda (installed on Python 3.7.6 WSL) Chrome 80.0.3987.132
Since FEniCS requires a Linux environment, build a Linux environment with WSL. Refer to other sites for the construction method. Linux has Unbuntu.
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
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
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.
Copy and execute Example ft03_heat.py on the FEniCS site. If you execute it as it is, an error will occur.
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.
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.
Obviously, you can complete the execution without any errors. Please note that some Official Examples have not been modified.
Recommended Posts