You can find detailed instructions for Installing MEEP on Linux Subsystem here:
https://github.com/NanoComp/meep/discussions/2423
1 Install Ubuntu (with WSL version 2): use Microsoft store to download and install distro
https://learn.microsoft.com/en-us/windows/wsl/install
https://towardsdatascience.com/setting-up-a-data-science-environment-using-windows-subsystem-for-linux-wsl-c4b390803dd
2 Install Conda (Miniconda):
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p miniconda3
export PATH=miniconda3/bin:$PATH ---- path to miniconda3 bin folder
2.1 In case if the base (root) doesn't appear in the terminal:
~/miniconda3/bin/conda init bash (recommended)
~/miniconda3/bin/conda init zsh (recommended)
or
export PATH=/home/<user /miniconda3/bin:$PATH
or
source /home/<user /miniconda3/bin/activate
This command will add the command in " " to bashrc file, so every time ubuntu starts, the code will be executed:
echo "source /home/<user /miniconda3/bin/activate" >> ~/.bashrc
Install meep from
-https://meep-hr.readthedocs.io/en/stable/Installation/
or
-https://meep.readthedocs.io/en/latest/Installation/ (recommended)
The codes are copied here for convenience (3.1 and 3.2).
3.1 Meep:
conda create -n meep -c chogan -c conda-forge pymeep
source activate pmeep
or
conda create -n meep -c conda-forge pymeep pymeep-extras (recommended)
source activate meep
3.2 Parallel Meep:
conda create -n pmeep -c chogan -c conda-forge pymeep-parallel
source activate pmeep
or
conda create -n pmeep -c conda-forge pymeep==mpi_mpich_ (recommended)
source activate pmeep
use following codes if you want to install packages on meep environment:
conda install -c conda-forge <some-package>
4.1 install jupyterlab on meep environment
conda activate meep
conda install -c conda-forge jupyterlab
4.1.1 Access to Jupyter
conda activate meep
jupyter lab --no-browser
jupyter notebook --no-browser
Copy the the URL to your browser in windows.
4.2 Install Spyder
conda activate meep
conda install -c conda-forge spyder
conda install -c conda-forge ipython_genutils
conda install -c conda-forge spyder-kernels
4.2.1 Run Spyder on Mobaxterm (recommended):
Install Mobaxterms from https://mobaxterm.mobatek.net/download-home-edition.html
Run the following codes:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libxcursor-dev
sudo apt-get install alsa
sudo apt install libegl1-mesa libegl1
sudo apt-get install python3-pyqt5.qtwebkit
Spyder
visit: https://www.youtube.com/watch?v=gByRjL1HWII&ab_channel=ValeriaItzelArteagaMu%C3%B1iz if the display didn't work for spyder
4.2.2 Run Spyder on X-server:
Install VcXsrv on windows from: https://sourceforge.net/projects/vcxsrv/
Run the followng codes:
sudo apt-get install libxcursor-dev
sudo apt-get install alsa
sudo apt install libegl1-mesa libegl1
open .bashrc file as text or try the following code:
nano ~/.bashrc
copy and paste the following codes to the end of .bahsrc file:
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2 /dev/null):0
export LIBGL_ALWAYS_INDIRECT=1
export QT_QPA_PLATFORM=offscreen
save the text file: (press Ctrl-X, then press y and the enter key if you used "nano ~/.bashrc" code)
Lunch VcXsrv and set the display number to 0 and select multiple windows
Enable the connection from public and private networks to VcXsrv from Firewall Setting
spyder
excute the following codes (examples/straight-waveguide.ipynb) to test your meep installation:
import meep as mp
import numpy as np
from matplotlib import pyplot as plt
print(mp.version)
cell = mp.Vector3(16,8,0)
geometry = [mp.Block(mp.Vector3(mp.inf,1,mp.inf),
center=mp.Vector3(),
material=mp.Medium(epsilon=12))]
sources = [mp.Source(mp.ContinuousSource(frequency=0.15),
component=mp.Ez,
center=mp.Vector3(-7,0))]
pml_layers = [mp.PML(1.0)]
resolution = 10
sim = mp.Simulation(cell_size=cell,
boundary_layers=pml_layers,
geometry=geometry,
sources=sources,
resolution=resolution)
sim.run(until=200)
eps_data = sim.get_array(center=mp.Vector3(), size=cell, component=mp.Dielectric)
plt.figure()
plt.imshow(eps_data.transpose(), interpolation='spline36', cmap='binary')
plt.axis('off')
plt.show()
ez_data = sim.get_array(center=mp.Vector3(), size=cell, component=mp.Ez)
plt.figure()
plt.imshow(eps_data.transpose(), interpolation='spline36', cmap='binary')
plt.imshow(ez_data.transpose(), interpolation='spline36', cmap='RdBu', alpha=0.9)
plt.axis('off')
plt.show()
In case of an error while importing meep (python -c 'import meep' or python3 -c 'import meep'):
conda activate meep
conda install -c conda-forge libgcc3
conda install -c conda-forge gsl
In the Jupyter lab or Spyder you should be able to see a waveguide and Ez-field distribution. Amazing!!!!
Tested on subsystem Ubuntu 20.04 LTS on windows 10.
visit following websites for more information on Meep installation:
- https://novelresearch.weebly.com/installing-meep-in-windows-8-via-cygwin.html
- http://jdj.mit.edu/wiki/index.php?title=Meep_Installation&printable=yes
- https://www.youtube.com/watch?v=pxIJTGiBdWs
- http://lordamit.blogspot.com/2011/10/tutorial-meep-in-ubuntu-complete.html?view=classic
- https://www.fzu.cz/~dominecf/meep/