Installation 👋#

This page will get you set up with Tidy3D and running a simple example.

Getting Started#

Before using Tidy3D, you must first sign up for a user account.

By signing up for a free account, you can obtain an API key here. You can also manage your simulation jobs and access graphic user interface if needed.

Managing API Keys#

Quick Configuration#

If you wish to install the Tidy3D Python API locally, the following instructions should work for most users.

pip install --user tidy3d
tidy3d configure --apikey=XXX

Testing the API Configuration#

To test that the configuration is working from the python browser, you can perform:

import tidy3d.web as web # if needed
web.test()

If those commands did not work, there are advanced installation instructions below, which should help solve the issue.

Advanced Key Management#

Now that tidy3d is installed on your python distribution, we need to link it with your account. First you should copy your “API key” from your account page on the web interface. To find it, sign in and navigate to the account page by clicking the “Account Center” icon on the left-hand side. Then, find the “API key” tab on the right hand side of the menu and copy your API key from there.

We’ll refer to that key as XXX in the following instructions.

The simplest way to link your account is by typing

tidy3d configure

and pasting the API key when prompted. Note that one can also specify the API key directly in the configure command as

tidy3d configure --apikey=XXX

Alternatively, the API key can be set up using the environment variable SIMCLOUD_APIKEY as:

export SIMCLOUD_APIKEY="XXX"

Finally, one may manually set the API key directly in the configuration file where Tidy3D looks for it.

The API key must be in a file called .tidy3d/config located in your home directory, with the following contents

apikey = "XXX"

You can manually set up your file like this, or do it through the command line line:

echo 'apikey = "XXX"' > ~/.tidy3d/config

Note the quotes around XXX.

Note that Windows users will most likely need to place the .tidy3d/config file in their C:\Users\username\ directory (where username is your username).

Package Version Management#

Tidy3D and its dependencies can be installed from the command line via pip, which is installed with Python when the new environment is created. Simply run

pip install tidy3d

and the latest version of Tidy3D will be installed in this environment. To test whether the installation was successful you can run

python -c "import tidy3d as td; print(td.__version__)"

If the installation is successful, you should see the client version of Tidy3D being displayed. Now you can open your favorite Python IDE and start creating Tidy3D simulations!

To get a specific version eg. x.y.z of tidy3d, including the “pre-release” versions, one may specify the version as follows:

pip install tidy3d==x.y.z

The documentation for the most recent release is marked as “latest” and is available here. The documentation page also allows one to select the state of the docs based on version by toggling the dropdown in the bottom left corner.

Advanced Installation Instructions#

Some users or systems may require a more specialized installation, which we will cover below.

If you already have Python installed on your computer, it is possible that some packages in your current environment could have version conflicts with Tidy3D. To avoid this, we strongly recommend that you create a clean Python virtual environment to install Tidy3D.

We recommend using the Mamba package management system to manage your Python virtual environment as well as installing Tidy3D. You can install Mamba conveniently following these instructions.

After you install Anaconda, open the Anaconda Prompt and enter

mamba create –n tidy3d_env python==3.10 -c conda-forge

to create a new environment. tidy3d_env is the name of the new environment, which can be changed to your personal preference. Python version 3.10 and its associated packages will also be installed in this new environment by adding python==3.10. After the environment is created, we need to activate it by

mamba activate tidy3d_env

You are now ready to install Tidy3D in your new environment, which will be discussed in the next section. More information about Conda environment management tools can be found here.

Next Steps#

That should get you started!

To see some other examples of Tidy3D being used in large scale photonics simulations, see Examples.

To learn more about the many features of Tidy3D, check out our Feature Walkthrough.

Or, if you’re interested in the API documentation, see API Reference.