This repository contains the code to generate simulation circuits files (.cir), subcircuits files (.sub), run simulations on NGSpice and plot the results. All features are divided in services (see services directory) in order to consume them on demand by an interface.
- Create a file for defining templates instead of using main.py
- Create a TestCase for Default Templates
- Plot TimeMeasures vs # Simulation with error bars
- Generate .cir and .sub files on each simulation dir instead of a unique file
- Generate examples dir with default .sub and .cir files
- Purge a given number o simulations to avoid cache effect
- Save Networks in another .sub file in order to save the generation time
- Create TimeMeasure tables from log files
- Implement Heaviside terms plot method
- Implement animated I-V plot method
- Add more models (Biolek, between others)
- Improve plots (curves visibility, labels, etc)
- Create UI - Frontend
-
/models: subcircuit (.sub) files with memristor models (Pershin, Vourkas, Biolek, etc). These files have the dynamic parameters of the memristor.
-
/services:
circuitfileservice.py
: Circuit file (.cir) generation. Circuit file contains subcircuits dependencies, componentes instance, analysis commands and control commands. Simulation CSV file name and path are written here.subcircuitfileservice.py
: Subcircuit file (.sub) generation. Subcircuit file contains memristor model parameters, other models dependencies, sources, componentes and control commands. These files are saved in the /models directory.plotterservice.py
: Plotting service to generate I-V and State-Time curves for particular simulations, comparative plots between all the simulations in a folder and a sub-plot figure for all simulations in folder.directoriesmanagementservice.py
: Paths finding and folders creation.ngspiceservice.py
: Wrapper for NGSpice simulation with time measure acquisition commands.timemeasureservice.py
: Time measure of simulations logic.
-
/simulation_results:
- /<model_name>_simulations
- /<simulation_template_name>
- /figures: Simulation plots.
- /logs: Simulation logs with NGSpice output and time measures.
- Simulation results (csv files)
- /<simulation_template_name>
- /<model_name>_simulations
-
main.py
: Main program file. -
constants.py
: Enum objects with constants used in the project. -
representations.py
: Dataclasses representations used in the project. -
requirements.txt
: Dependencies needed to run code.
- Python3
- Numpy
- Pandas
- Networkx
- Matplotlib
- NGSpice (with executable path on PATH environment variable)
- Clone the repository
- Install NGSpice and add its exec file to the PATH variable:
- Windows: http://ngspice.sourceforge.net/download.html
- Linux:
sudo apt-get install ngspice
- Install the required dependencies (using a virtual environment is recommended) -
pip install -r requirements.txt
- At the end of the
main.py
file, you can modify thesimulate
function to use one of the template simulations for a given model and generate the desired plots. Supported templates, models and plots are still limited but the plan is to add more.- Simulation templates:
DEFAULT_TEST
,DEFAULT_NETWORK
,DEFAULT_NETWORK_WITH_EDGE_REMOVAL
,DI_FRANCESCO_VARIABLE_AMPLITUDE
,DI_FRANCESCO_VARIABLE_BETA
,QUINTEROS_EXPERIMENTS
,RANDOM_REGULAR
,WATTS_STROGATZ_CIRCULAR_REGULAR
,WATTS_STROGATZ
- Plot Types:
IV
,IV_OVERLAPPED
,IV_LOG
,IV_LOG_OVERLAPPED
,MEMRISTIVE_STATES
,MEMRISTIVE_STATES_OVERLAPPED
- Models:
PERSHIN
andVOURKAS
- Amount Iterations: Any integer. Amount of times the template will be simulated. Used to compute average time measure of simulations.
- Simulation templates:
if __name__ == "__main__":
simulate(
simulation_template=SimulationTemplate.DEFAULT_TEST,
plot_types=[
PlotType.IV, PlotType.IV_OVERLAPPED, PlotType.IV_LOG, PlotType.IV_LOG_OVERLAPPED,
PlotType.MEMRISTIVE_STATES, PlotType.MEMRISTIVE_STATES_OVERLAPPED
],
model=MemristorModels.PERSHIN, amount_iterations=100
)
- Execute
main.py
withpython3 main.py