Circuits

Note: see Netlists to learn how circuit files should look.

Circuits zip structure

The structure inside the circuits file has to be a subset of the following folders:

  • capacitor (circuits with only capacitors)

  • inductor (circuits with only inductors)

  • mixed (circuits with a mix of capacitors, inductors, resistors)

  • quickstart (circuits that shall be shown at the top as a preview selection, those are presolved files and limited to to the provided ones)

  • resistor (circuits with only resistors)

  • symbolic (circuits that have variables (R1, C1, L1, V1) as values (resistance, capacitance, voltage etc.)) this only makes sense for small circuits and is likely to crash for capacitors and inductors

  • wheatstone (the bridge circuit used for determining the value of an unknown resistor)

  • magnetic (circuits that represent magnetic circuits)

Create circuit files that end with .txt and sort them into the according folders. To host circuits with the simplipfy page, zip the folders or a subset of the folders into a file called Circuits.zip. The zip file has to be in the Pyodide folder. If you arent sure where to place the file search for Circuits.zip in the distributed code. The zip file can be created with any zip program except powershell zip util.

Host own circuit files

Create a venv to generate svg files

If you already set up a venv for developing you can use that and skip ahead to the next section. Open a PowerShell. Create a python virtual venv with python -m venv ./circuitsGenVenv (this creates the venv in the directory you are currently in). The venv has to be at least Python 3.8. Activate the venv with .\circuitsGenVenv\Scripts\Activate.ps1. From simplipfy packages download:

  • lcapyInskale

  • schemdrawInskale

If you are not on the latest version take the packages from your download path/to/sourceCode/Pyodide/Packages and save them where you created the venv. Alternatively you can replace .\ with path\to\packages\ and save them wherever you want. Then run in Powershell:

pip install .\schemdrawInskale-<version>-none-any.whl
pip install .\lcapyInskale-<version>-none-any.whl

It is important to first install schemdrawInskale then install lcapyInskale. Otherwise the installation of lcapyInskale might fail due to missing dependencies. Navigate into to <sourceCode>/Pyodide or simply Pyodide (you should see e.g. the folders Circuits, Packages, Scripts, …).

Generate svg files

With the venv where the packages lcapyInskale, schemdrawInskale, generalizeNetlistDrawing, simplipfy are installed, execute from the project base directory:

.\Scripts\generateSVGFiles.ps1

This might take some time and should produce output that looks like this:

generating: Circuits\capacitor\00_capacitor_row3.svg
generating: Circuits\capacitor\01_capacitor_parallel3.svg
generating: Circuits\capacitor\07_capacitors_mixed_simple.svg
...

Package circuits to zip

Now you have to zip the new circuits folder, commit and push your changes to GitHub. Don’t forget to update your gh-pages branch with git subtree push --prefix Pyodide origin gh-pages if you forked the repository. If you forked and don`t update the gh-pages branch the changed circuits will not be on your GitHub Page. If you downloaded the source code, pushing to the main branch of your repository will trigger the GitHub Page build. If you serve them via a http(s) server, simply overwriting the Circuits.zip file will yield the new files on the webserver.

Upload own circuit files

In the tab custom circuits you can upload a circuit file (zip-file). The uploaded circuits are evaluated and shown on the page custom circuits. The circuits aren’t persistent and will be removed if the page is reloaded, the tab is closed or the browser is closed.

Auto download

You can host your own circuits.zip file without hosting simplipfy. Put the circuits.zip file on a server and copy the direct download link. If you paste the direct download link into a browser the file download has to start without any extra steps on a website. With this link got to simplipfy.org -> navigate to tools -> create a qr-code. The qr-code holds the following link: www.simplipfy.org/#<yourDirectDownloadLink>. This will automatically ask the user if the file shall be downloaded on site entry. If the user chooses to download the file, the circuits viewed page will automatically change to the custom circuits tab. There the user is asked to upload the downloaded file. We know it would be nicer to automatically use the downloaded file but we are limited by strict CORS policy force by the browser. The download will happen in a separate browser window. If the user has to log it should still work. We tested successfully with moodle. A save bet is the link to a file in a GitHub repository. There you have to copy the link to view raw to get a direct download link.