Skip to content

Commit

Permalink
Mostly worked on software installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
parkeraa committed Jan 10, 2024
1 parent 74286f5 commit d17bc8e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 46 deletions.
4 changes: 2 additions & 2 deletions book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ parts:
- file: pages/software
sections:
- file: pages/sewsltup
- file: pages/git_and_github
- file: pages/vscode
- file: pages/git_and_github
- file: pages/python
- file: pages/klayout
- file: pages/laboratory_tools
Expand All @@ -36,8 +36,8 @@ parts:
- file: pages/waveguides_tir
- file: pages/waveguides_polarization
- file: pages/ray_optic_model
- file: pages/waveguides_mode_solvers
- file: pages/waveguides_modelling
- file: pages/waveguides_mode_solvers
- file: pages/waveguides_fdtd_solvers
- file: pages/passive_components
sections:
Expand Down
96 changes: 55 additions & 41 deletions book/pages/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,49 @@ downloading.

:::{note}

For Windows, it's easiest to download the script in the Ubuntu terminal using
curl so you don't have to copy it from the Windows filesystem over to the
Ubuntu. Even though you're on Windows, since you're installing it to the Ubuntu
system, download the Linux installer!
For Windows, it's easiest to download the script in the Ubuntu terminal in VSCode.
Follow the Linux instructions in the [Quick Command Line Install](https://docs.conda.io/projects/miniconda/en/latest/#quick-command-line-install)
section of the Miniconda install page.
:::

## Virtual Environments

It's best practice to use a **virtual environment**. A virtual environment is
simply an environment that is isolated from your main Python installation
or any other installation on your computer. You can think of it as a sandbox;
you can have as many of them as you want, and they don't interact with each
other. They're especially useful if you need to have different versions of
the a library for different programs.
They can both be on your computer, but in their own walled off areas.

In Python, virtual environments are also very easy to create and destroy.
This way, if you mess up your environment, it only costs you a few seconds to
delete it and start again. The nice thing about a requirements file that pins
versions of the software is that once you've verified all the versions work
well together, you never have to worry about compatability or recreating the
setup you were originally using again. Simply install your requirements file,
or give it to someone else, and you can create the same environment anywhere
you want.

While Python has a virtual environment mechanism built in to the language
([venv](https://docs.python.org/3/library/venv.html)), since we're using
conda to access Python, we'll use its virtual environment management features
as well.

To create an environment, in this case named ``photonics``, run:

```bash
conda create --name photonics python
```

You can even specify a specific version of Python, if you'd like to use the
latest and greatest version:

```bash
conda create --name photonics python=3.11
```


## Package Managers

Python has a robust open-source community. To that end, there exist several
Expand All @@ -55,7 +92,20 @@ ones you will become very familiar with include:
that will be very familiar to MATLAB users.
* gdsfactory: A Python library for generating GDS layouts.

It's very easy to install packages from PyPI. Most base installations of Python
Conda itself also includes methods for installing packages from their database.
In most cases, we recommend installing via PyPI, but one package we will need
is only available on conda. In general, if using a conda environment, it is
recommended to install all conda packages before installing via PyPI. For instance,
we will use a finite-difference time-domain (FDTD) solver called [MEEP](https://meep.readthedocs.io/en/latest/)
in this course. It can be installed on a conda environment by activating the
environment then running


```bash
conda install -c conda-forge pymeep pymeep-extras
```

It's also very easy to install packages from PyPI. Most base installations of Python
include "pip", a tool used to install other packages from PyPI. It can be
invoked from the command line, like so:

Expand Down Expand Up @@ -128,39 +178,3 @@ line:
pip install -r requirements.txt
```

## Virtual Environments

It's best practice to use a **virtual environment**. A virtual environment is
simply an environment that is isolated from your main Python installation
or any other installation on your computer. You can think of it as a sandbox;
you can have as many of them as you want, and they don't interact with each
other. They're especially useful if you need to have different versions of
the a library for different programs.
They can both be on your computer, but in their own walled off areas.

In Python, virtual environments are also very easy to create and destroy.
This way, if you mess up your environment, it only costs you a few seconds to
delete it and start again. The nice thing about a requirements file that pins
versions of the software is that once you've verified all the versions work
well together, you never have to worry about compatability or recreating the
setup you were originally using again. Simply install your requirements file,
or give it to someone else, and you can create the same environment anywhere
you want.

While Python has a virtual environment mechanism built in to the language
([venv](https://docs.python.org/3/library/venv.html)), since we're using
conda to access Python, we'll use its virtual environment management features
as well.

To create an environment, in this case named ``photonics``, run:

```bash
conda create --name photonics python
```

You can even specify a specific version of Python, if you'd like to use the
latest and greatest version:

```bash
conda create --name photonics python=3.11
```
5 changes: 3 additions & 2 deletions book/pages/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ for this course:
* [Open](https://marketplace.visualstudio.com/items?itemName=sandcastle.vscode-open) (allows you to open files from the code editor tree in their default program)
* [vscode-icons](https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons) (some eye-candy, makes it easier to find files in the tree)

## Connect to WSL
## Connect to WSL (Windows Machines)

1. Open VSCode. You can setup a theme and other things.
1. If you are using WSL, make sure to [open VSCode in your WSL environment](https://code.visualstudio.com/docs/remote/wsl#_open-a-remote-folder-or-workspace). You can double-check that you're connected by looking at the colored box in the bottom left-hand corner of VSCode. If VSCode is connected to WSL it will say "WSL" in this box. If it doesn't, then click the box. A menu will pop up. Click the option "Connect to WSL" and VSCode will now be connected to WSL.
2. Connect to WSL. There are a few ways to do this, but the easiest is to look for a small colored box in the bottom left-hand corner of VSCode. If VSCode is connected to WSL it will say "WSL" in this box. If it doesn't, then click the box. A menu will pop up. Click the option "Connect to WSL" and VSCode will now be connected to WSL. More information about WSL in VSCode and other ways to connect can be found in [VSCode's WSL doc page](https://code.visualstudio.com/docs/remote/wsl#_open-a-remote-folder-or-workspace).
3. From now on, all coding and installing should be done through WSL using the VSCode terminal, and since WSL is a linux system, the linux install instructions should be used.
2 changes: 1 addition & 1 deletion book/pages/waveguides_mode_solvers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"\n",
"2. The second thing to notice is that the mode also has non-zero electric field *outside* of the waveguide. This part of the mode is called the evanescent field, and decays exponentially. In order to visualize both the sinusoidal and exponentially decaying parts of the modes, a slice of the mode is also plotted in blue just above the waveguide. This slice is the magnitude of the electric field, which can be positive and negative, at $z=0$.\n",
"\n",
"3. The third thing to notice is that the electric field is discontinuous in the y-direction when it crosses a dielectric interface. This turns out to be a boundary condition that is a fundamental property of Maxwell's equations, but depends on the direction the field is pointing. Any component of the field perpindicular to the boundary will be discontinous, and any component of the field parallel to the boundar will be continuous. Since we have plotted just the y-component of the field, it is discontinuous when it crosses vertical boundaries, but continous when it crosses horizontal boundaries.\n",
"3. The third thing to notice is that the electric field is discontinuous in the y-direction when it crosses a dielectric interface. This turns out to be a boundary condition that is a fundamental property of Maxwell's equations, but depends on the direction the field is pointing. Any component of the field perpindicular to the boundary will be discontinous, and any component of the field parallel to the boundary will be continuous. Since we have plotted just the y-component of the field, it is discontinuous when it crosses vertical boundaries, but continous when it crosses horizontal boundaries.\n",
"\n",
"Modes that are dominately polarized in the y-direction are called transverse electric (TE) modes. TE modes are polarized parallel to the substrate and perpindicular (transverse) to the direction of propagation. \n",
"\n",
Expand Down

0 comments on commit d17bc8e

Please sign in to comment.