├── .gitignore ├── .travis.yml ├── README.md ├── appveyor.yml └── vendor ├── Fang - JSIM - Ext Abs ISEC'89.pdf ├── Manual JSIM+OPTIMIZER-V7.pdf └── jsim ├── CMakeLists.txt ├── HISTORY ├── Makefile ├── README ├── device ├── CMakeLists.txt ├── Makefile ├── cap.c ├── device.c ├── inductor.c ├── isource.c ├── jj.c ├── mutual.c ├── picture.c ├── resistor.c ├── vsource.c └── xline.c ├── examples ├── cntr ├── jjiv └── jtl ├── include ├── extern.h ├── global.h ├── jsim.h └── setup.h ├── jsim_n-COPYRIGHT ├── jsim_n-README ├── jsim_n-tests ├── CMakeLists.txt ├── README ├── ah.c ├── benchmarks ├── dotest ├── rt.c ├── test0.js ├── test1.js ├── test10n.js ├── test11n.js ├── test2.js ├── test3.js ├── test4.js ├── test5.js ├── test6.js ├── test7n.js ├── test8n.js ├── test9n.js └── testlog ├── jsimtxt ├── CMakeLists.txt ├── Makefile ├── debug.c ├── function.c ├── matrix.c ├── misc.c ├── model.c ├── morspace.c ├── print.c ├── setup.c ├── srchsort.c ├── subckt.c ├── topology.c └── tran.c ├── main.c ├── main_n.c ├── manual.dvi ├── manual.ms ├── manual.pdf ├── manual.ps └── noise.awkf /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .*.swp 3 | .*DS_Store 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - clang 4 | - gcc 5 | 6 | matrix: 7 | include: 8 | - os: osx 9 | osx_image: xcode8 10 | env: 11 | - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" 12 | 13 | - os: osx 14 | osx_image: xcode8 15 | env: 16 | - MATRIX_EVAL="brew install gcc5 && CC=gcc-5 && CXX=g++-5" 17 | 18 | before_install: 19 | - eval "${MATRIX_EVAL}" 20 | 21 | notifications: # set notification options 22 | email: 23 | recipients: 24 | - stark@coldlogix.com 25 | 26 | branches: 27 | only: 28 | - master 29 | 30 | 31 | # Build steps 32 | script: 33 | - mkdir vendor/jsim/build 34 | - cd vendor/jsim/build 35 | - cmake .. && make 36 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JSIM Superconducting Circuit Simulator 2 | ====================================== 3 | 4 | This is JSIM, a Josephson Junction aware spice simulator 5 | originally written by Emerson S. Fang as part of his work 6 | in Ted Van Duzer's lab at the University of California, Berkeley 7 | 8 | Quick Start 9 | =========== 10 | 11 | If you're new to JSIM, then welcome. JSIM is meant for superconducting 12 | simluations of Jospehson Junction based technologies, and does not 13 | have the full features that you may be used to in other spice variants. 14 | If you're not looking to simulate superconducting circuits, it's very 15 | unlikely that you want to use JSIM. 16 | 17 | This repository has been updated to use CMake to build, and should work 18 | on a wide variety of different architectures. It's known to compile on 19 | Mac OSX Sierra and Ubuntu, but should compile on most any unix-like 20 | operating system. It is not currently building on windows. Please make 21 | your interest known if you would like to run JSIM on windows. 22 | 23 | * linux/osx [![Build Status](https://travis-ci.org/coldlogix/jsim.svg?branch=master)](https://travis-ci.org/coldlogix/jsim) 24 | * win32 [![Build status](https://ci.appveyor.com/api/projects/status/472h0i7icsdekb1n?svg=true)](https://ci.appveyor.com/project/coldlogix/jsim) 25 | 26 | Here is the super quick guide to get up and running: 27 | 28 | Install CMake, and an appropriate build environment on your system. 29 | ```bash 30 | git clone https://github.com/coldlogix/jsim.git 31 | cd jsim/vendor/jsim/ 32 | mkdir build 33 | cd build 34 | cmake .. 35 | make 36 | ``` 37 | 38 | This should produce both jsim and jsim_n executables. The jsim_n 39 | version includes stochastic noise simulation added by J. Satchell in 1995, 40 | and probably will eventually just become part of jsim in this repository 41 | in the future. 42 | 43 | Branches 44 | ======== 45 | 46 | This repository attempts to collect and order close to 30 years of 47 | variants of the JSIM project. There is an attempt to provide branches 48 | for all of the versions of JSIM encountered, and to try to parent them 49 | from other branches in an appropriate way such that if you have changes 50 | that you've made, you can easily integrate those with the repository 51 | and contribute your changes back to the community. 52 | 53 | The following branches are available, and their origin and histories are 54 | annotated in the log messages for the commits for each of the branches. 55 | 56 | * master 57 | * vendor_ortlepp_jsim_n 58 | * vendor_stellenbosch_jsim_n 59 | * vendor_whiteley_jsim_2.0d 60 | * vendor_whiteley_jsim_2.0e 61 | * vendor_yamanashi_pjsim 62 | 63 | History 64 | ======= 65 | 66 | This git repository is an attempt to collect and consolidate all 67 | of the various revisions to jsim that have occured over the years 68 | and provide one central manageable point for future work on JSIM. 69 | 70 | The original thesis from Emerson S. Fang was written in 1989, so 71 | there is a very deep and old history for JSIM, with many many people 72 | touching and modifying the source over many many years. I have 73 | attempted as best as possible to organize and properly parent the 74 | various versions I've found in this repository, using branches for 75 | each new version I've found. 76 | 77 | The various collection formats (tar, zip, raw directories and others) 78 | have diverged over the many years, and so the directory structure in 79 | the original sources is not always the same across versions of JSIM 80 | that I've found "in the wild". I've attempted to checkin the raw 81 | versions as close to the formats I've found them in as possible, and 82 | then to normalize the versions, hoping that this will make it easier 83 | for others to merge any changes that they've made into the repository. 84 | 85 | Contributing 86 | ============ 87 | 88 | If you have changes or enhancements that you'd like to contribute, 89 | or suggestions for ways to make this repository more useful to you 90 | or others, please feel free to create a pull requests or issue in 91 | github, or contact me directly. 92 | 93 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Specify version format 2 | version: "{build}" 3 | 4 | # Operating system (build VM template) 5 | os: Visual Studio 2015 6 | 7 | # build platform, i.e. Win32 (instead of x86), x64, Any CPU. This setting is optional. 8 | platform: 9 | - Win32 10 | - x64 11 | 12 | # specify custom environment variables 13 | environment: 14 | MSVC_DEFAULT_OPTIONS: ON 15 | 16 | # build configuration, i.e. Debug, Release, etc. 17 | configuration: 18 | - Debug 19 | - Release 20 | 21 | # scripts that are called at very beginning, before repo cloning 22 | init: 23 | - cmd: cmake --version 24 | - cmd: msbuild /version 25 | 26 | # clone directory 27 | clone_folder: C:\projects\jsim 28 | 29 | # branches to build 30 | branches: 31 | # whitelist 32 | only: 33 | - master 34 | # blacklist 35 | #except: 36 | # - gh-pages 37 | 38 | # scripts that run after cloning repository 39 | install: 40 | - ps: cd C:\projects\jsim 41 | 42 | # scripts to run before build 43 | before_build: 44 | - cmd: cd C:\projects\jsim\vendor\jsim 45 | - cmd: md build 46 | - cmd: cd build 47 | - cmd: if "%platform%"=="Win32" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 48 | - cmd: if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64 49 | - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% .. 50 | 51 | build: 52 | project: C:\projects\jsim\vendor\jsim\build\jsim.sln # path to Visual Studio solution or project 53 | parallel: true # enable MSBuild parallel builds 54 | # verbosity: quiet # MSBuild verbosity level (quiet|minimal|normal|detailed) 55 | 56 | test: off 57 | #test_script: 58 | # - cmd: ctest --build-config %configuration% --parallel 4 --output-on-failure 59 | 60 | -------------------------------------------------------------------------------- /vendor/Fang - JSIM - Ext Abs ISEC'89.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldlogix/jsim/ba1aa007dc1798cecf6ce4862f3ba6e930aa5f47/vendor/Fang - JSIM - Ext Abs ISEC'89.pdf -------------------------------------------------------------------------------- /vendor/Manual JSIM+OPTIMIZER-V7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldlogix/jsim/ba1aa007dc1798cecf6ce4862f3ba6e930aa5f47/vendor/Manual JSIM+OPTIMIZER-V7.pdf -------------------------------------------------------------------------------- /vendor/jsim/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(jsim C) 4 | 5 | add_subdirectory(device) 6 | add_subdirectory(jsimtxt) 7 | add_subdirectory(jsim_n-tests) 8 | 9 | include(CheckFunctionExists) 10 | 11 | CHECK_FUNCTION_EXISTS(pow NOT_NEED_LIBM) 12 | if(NOT_NEED_LIBM) 13 | set(LIB_MATH "") 14 | else() 15 | set(CMAKE_REQUIRED_LIBRARIES m) 16 | CHECK_FUNCTION_EXISTS(pow HAVE_LIBM) 17 | if(HAVE_LIBM) 18 | set(LIB_MATH m) 19 | else() 20 | message(FATAL_ERROR "No libm found for math support") 21 | endif() 22 | endif() 23 | 24 | if (WIN32) 25 | # Win32 needs to know to define M_PI 26 | add_definitions(-D_USE_MATH_DEFINES) 27 | endif (WIN32) 28 | 29 | add_executable(jsim 30 | main.c 31 | 32 | include/jsim.h 33 | include/global.h 34 | include/extern.h 35 | include/setup.h 36 | ) 37 | 38 | target_include_directories(jsim 39 | PUBLIC 40 | include 41 | ) 42 | 43 | target_link_libraries(jsim 44 | PUBLIC 45 | jsimtxt 46 | jsimdevice 47 | ${LIB_MATH} 48 | ) 49 | 50 | 51 | add_executable(jsim_n 52 | main_n.c 53 | 54 | include/jsim.h 55 | include/global.h 56 | include/setup.h 57 | ) 58 | 59 | target_include_directories(jsim_n 60 | PUBLIC 61 | include 62 | ) 63 | 64 | target_link_libraries(jsim_n 65 | PUBLIC 66 | jsimtxt 67 | jsimdevice 68 | ${LIB_MATH} 69 | ) 70 | #doc: 71 | # nroff -ms manual.ms 72 | # nroff -ms noise.ms 73 | 74 | -------------------------------------------------------------------------------- /vendor/jsim/HISTORY: -------------------------------------------------------------------------------- 1 | Jsim has a long history with many contributors making various changes 2 | for various purposes. This file is an attempt to document this particular 3 | release in a way that can be easily extended by others. Please add to this 4 | history file if you make modifications 5 | 6 | The version started as jsim_2.0e from Steve Whiteley, as downloaded from 7 | the Whiteley Research website 8 | May 3, 2017 9 | 10 | http://www.wrcad.com/ftp/pub/jsim-2.0e.tar.gz 11 | 12 | File information: 13 | jsim-2.0e.tar.gz 08-Nov-2014 17:23 125K 14 | 15 | 2017-07-22 Jonathan Stark 16 | 17 | CMake file was added 18 | 19 | Merged the stochastic extension of jsim for jsim_n by J. Satchell (satchell@dra.hmg.gb) 20 | 21 | 22 | -------------------------------------------------------------------------------- /vendor/jsim/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDE = include 2 | CFLAGS = -O -g -I${INCLUDE} 3 | LINKS = -lm 4 | CC = cc 5 | # for SYSV compilers that gag on ranlib (like SCO's), comment out next line 6 | LIBRARY = ranlib 7 | 8 | jsim: main.o jsimtxt.a device.a 9 | $(CC) -O -o jsim main.o jsimtxt.a device.a jsimtxt.a ${LINKS} 10 | 11 | clean:: 12 | rm -f *.o *.a jsimtxt/*.o device/*.o jsim 13 | 14 | .c.o: $*.c 15 | $(CC) ${CFLAGS} -c $*.c 16 | 17 | 18 | jsimtxt.a:: 19 | cd jsimtxt; make ${LIBRARY} 20 | 21 | device.a:: 22 | cd device; make ${LIBRARY} 23 | 24 | 25 | main.o: \ 26 | include/global.h \ 27 | include/jsim.h 28 | -------------------------------------------------------------------------------- /vendor/jsim/README: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0e 11/7/14 4 | * JSIM Release 2.0d 1/11/09 5 | * JSIM Release 2.0c 1/4/04 6 | * JSIM Release 2.0b 10/13/93 7 | * JSIM Release 2.0a 5/28/93 8 | * JSIM Release 2.0 10/24/92 9 | * 10 | * JSIM is a simulator for circuits containing Josephson Junctions. 11 | * 12 | * Author: Emerson Fang, 1991 13 | * University of California, Berkeley 14 | * Dept. of Electrical Engineering and Computer Sciences 15 | * Cryoelectronics Group, Professor Ted Van Duzer 16 | * 17 | * Subsequent work: Jay Fleischman, Steve Whiteley 18 | * 19 | *************************************************************************/ 20 | 21 | 2.0e note: 22 | 23 | Another round of compiler warning fixes, now no warnings in clang-3.3. 24 | Added a pdf manual. 25 | 26 | 2.0d note: 27 | The ftime call was replaced with gettimeofday, which is less obsolete 28 | and more portable. 29 | 30 | Converted all function calls to ANSI C style. 31 | 32 | Misc. small tweeks to avoid compiler warnings with recent compilers, 33 | e.g., gcc-4.2. 34 | 35 | Removed the old DOS junk, and renamed the unix makefiles to "Makefile". 36 | 37 | Fixed a bug in breakpoint setting in tran.c which caused seg faults. 38 | 39 | 40 | 2.0c note: 41 | Added jjiv example file. JSIM doesn't seem to do well when plotting 42 | an i-v curve for some reason. There appears to be strange behavior 43 | near the gap, possibly due to poor convergence due to the strong 44 | nonlinearity. There may be parameters that can be set to improve this. 45 | 46 | Added dvi and postscript versions of the "manual". 47 | 48 | Fixed bug: DEVI should now work if -r given. This gave a seg fault in 49 | previous release. 50 | 51 | This program is not under active development or maintenance. If you 52 | need an industrial-grade simulator for Josephson circuits, consider 53 | WRspice (http://www.wrcad.com). 54 | 55 | 56 | 2.0b note: 57 | Support for DJGCC port of gcc to DOS added. Use the djgcc.mak makefile. 58 | A go32.exe must exist on the search path for execution. This port is 59 | available on omnigate.clarkson.edu (no longer true in 1997). 60 | 61 | 2.0a notes: 62 | description of changes: 63 | 64 | 1. Informational print statements were interfering when the output 65 | was sent to the ejgraph program. These are now printed only in the 66 | rawfile (-r) mode. 67 | 68 | 2. There was uncertainty in the time point count which was entered 69 | into the jsim.raw file (-r option only) relative to the actual number 70 | of time points output. The two numbers now match. 71 | 72 | 3. An input line of ".end" is now legal, and causes input reading to stop 73 | for the current simulation. This was necessary for invocations of the 74 | form "jsim - - < catted_file", where in catted_file .end lines separate 75 | the jsim decks. 76 | 77 | 78 | 2.0 notes: 79 | This release of JSIM has new features not found in earlier releases: 80 | 81 | 1. Output data can be placed in a "rawfile" in the same format used 82 | by the Berkeley SPICE3 and NUTMEG programs. Thus, these programs 83 | can be used to display JSIM plots. In addition, a stand-alone 84 | program called GRAF is available for plotting rawfiles (not available, 85 | obsolete 1997). 86 | 87 | 2. Input files, and options, can be listed on the command 88 | line. If no files are listed, the standard input is read, as with 89 | previous JSIM versions. Each file is run in sequence. 90 | 91 | 3. Previous releases of JSIM dumped a number of debugging files 92 | into the current directory. In this release, no debugging files 93 | are created, unless requested with a command line option. In this 94 | case, only one file is created, which contains all of the information. 95 | 96 | In addition, files have been combined and the source tree altered to 97 | facilitate program maintenance. The files have been rewritten to be 98 | ansi compatible, with function prototypes in the extern.h file. 99 | 100 | 101 | Command line syntax: 102 | 103 | 104 | jsim [-options] [filenames] [-options] [filenames] ... [ redirection ] 105 | 106 | 107 | 108 | Recognized options are d, r, or nothing, following a '-'. 109 | d toggle debugging, which dumps a file jsim.dbg (initially off). 110 | r toggle use of a rawfile jsim.raw for output (initially off). 111 | - read the standard input. 112 | 113 | The d,r options can be combined. The filenames jsim.dbg and jsim.raw 114 | are hard coded. 115 | 116 | Other tokens on the command line are assumed to be file names 117 | to read for input. If no such tokens are found, the standard input 118 | is read. 119 | 120 | The options operate on files listed to the right of the option 121 | list, and are active until changed with another invocation. If 122 | no files are listed, the options are read before the standard 123 | input is read. 124 | 125 | When multiple files are simulated, enabled output to the jsim.dbg 126 | and jsim.raw files is appended. The first file to generate such 127 | output creates the file. If the file previously existed, it will 128 | be clobbered! If the rawfile option is not specified, files will 129 | be created in accordance with the .file lines in the input files. 130 | These file names should be unique, as new files are opened for 131 | each simulation. The .file lines are ignored if the rawfile option 132 | is used. 133 | 134 | 135 | examples: 136 | 137 | jsim file1 -d file2 -d file3 138 | will dump debug information while simulating file2. 139 | 140 | jsim file1 -rd - file3 n_plus, 119 | ((sub_cap *) data)->p_node); 120 | n_plus = add_node(n_plus, name, type, PLUS_NODE, bmarker); 121 | n_minus = getnode_subnode(((sub_cap *) data)->n_minus, 122 | ((sub_cap *) data)->m_node); 123 | n_minus = add_node(n_minus, name, type, MINUS_NODE, 124 | bmarker); 125 | return(add_cap(name, ((sub_cap *) data)->val, 126 | ((sub_cap *) data)->ic, n_plus, n_minus)); 127 | 128 | } /* switch */ 129 | 130 | return(NULL); 131 | 132 | } /* capsub_to_devlist */ 133 | 134 | 135 | device * 136 | add_cap(long name, double val, double ic, long n_plus, long n_minus) 137 | { 138 | char *data; 139 | dev_cap *temp; 140 | sub_cap *temp_sub; 141 | 142 | if (current_sub_def == NULL) 143 | { 144 | temp = (dev_cap *) mycalloc(1, sizeof(dev_cap)); 145 | 146 | temp->val = val; 147 | temp->ic = ic; 148 | temp->n_plus = n_plus; 149 | temp->n_minus = n_minus; 150 | 151 | data = (char *) temp; 152 | return(add_dev(name, CAP, data)); 153 | } 154 | else 155 | { 156 | temp_sub = (sub_cap *) mycalloc(1, sizeof(sub_cap)); 157 | 158 | temp_sub->val = val; 159 | temp_sub->ic = ic; 160 | temp_sub->n_plus = n_plus; 161 | temp_sub->n_minus = n_minus; 162 | temp_sub->p_node = scan_node(n_plus); 163 | temp_sub->m_node = scan_node(n_minus); 164 | 165 | data = (char *) temp_sub; 166 | return(add_sub((char *) name, CAP, data)); 167 | } 168 | 169 | } /* add_cap */ 170 | 171 | 172 | void 173 | cap_matrix() 174 | { 175 | dev_cap *temp; 176 | device *temp_dev; 177 | int exist; 178 | 179 | temp_dev = cap; 180 | 181 | while (temp_dev != NULL) 182 | { 183 | temp = (dev_cap *) temp_dev->data; 184 | 185 | if (temp->n_plus != GROUND ) 186 | { 187 | temp->mptr_pp = add_i_j(A_matrix, 188 | temp->n_plus, temp->n_plus, &exist); 189 | temp->mptr_pp->type = ORIGINAL; 190 | 191 | /* 192 | if (x_unknown[temp->n_plus] == NULL) 193 | { 194 | add_unknown(x_unknown, temp->n_plus); 195 | } 196 | */ 197 | x_unknown[temp->n_plus]->type = VOLT_TIME; 198 | 199 | add_source(b_source, temp->n_plus); 200 | 201 | } 202 | 203 | if ((temp->n_plus != GROUND) && 204 | (temp->n_minus != GROUND)) 205 | { 206 | temp->mptr_pm = add_i_j(A_matrix, 207 | temp->n_plus, temp->n_minus, &exist); 208 | temp->mptr_pm->type = ORIGINAL; 209 | 210 | temp->mptr_mp = add_i_j(A_matrix, 211 | temp->n_minus, temp->n_plus, &exist); 212 | temp->mptr_mp->type = ORIGINAL; 213 | } 214 | 215 | if (temp->n_minus != GROUND) 216 | { 217 | temp->mptr_mm = add_i_j(A_matrix, 218 | temp->n_minus, temp->n_minus, &exist); 219 | temp->mptr_mm->type = ORIGINAL; 220 | 221 | /* 222 | if (x_unknown[temp->n_minus] == NULL) 223 | { 224 | add_unknown(x_unknown, temp->n_minus); 225 | } 226 | */ 227 | x_unknown[temp->n_minus]->type = VOLT_TIME; 228 | 229 | add_source(b_source, temp->n_minus); 230 | } 231 | 232 | if (temp->n_plus == GROUND) temp->n_plus = ground_node; 233 | if (temp->n_minus == GROUND) temp->n_minus = ground_node; 234 | 235 | temp_dev = temp_dev->next_dev; 236 | } 237 | 238 | } /* cap_matrix */ 239 | 240 | 241 | void 242 | cap_trap(int source_only, double *hptr) 243 | { 244 | dev_cap *temp; 245 | device *temp_dev; 246 | double xn1, xn1d, yn1, yn1d, two_c_hn, sval; 247 | 248 | temp_dev = cap; 249 | 250 | while (temp_dev != NULL) 251 | { 252 | temp = (dev_cap *) temp_dev->data; 253 | 254 | two_c_hn = (temp->val + temp->val)/(*hptr); 255 | 256 | xn1 = *(x_unk_copy[temp->n_plus]->xpast); 257 | xn1d = x_unk_copy[temp->n_plus]->xdpast; 258 | 259 | yn1 = *(x_unk_copy[temp->n_minus]->xpast); 260 | yn1d = x_unk_copy[temp->n_minus]->xdpast; 261 | 262 | sval = two_c_hn*(xn1 - yn1) + temp->val*(xn1d - yn1d); 263 | 264 | if (temp->n_plus != ground_node) 265 | { 266 | if (source_only == FALSE) 267 | temp->mptr_pp->val = temp->mptr_pp->val + two_c_hn; 268 | 269 | b_src_copy[temp->n_plus]->val = 270 | b_src_copy[temp->n_plus]->val + sval; 271 | /* 272 | b_source[temp->n_plus]->val = b_source[temp->n_plus]->val 273 | + sval; 274 | */ 275 | } 276 | 277 | if ((temp->n_plus != ground_node) && 278 | (temp->n_minus != ground_node) && 279 | (source_only == FALSE)) 280 | { 281 | temp->mptr_pm->val = temp->mptr_pm->val - two_c_hn; 282 | 283 | temp->mptr_mp->val = temp->mptr_mp->val - two_c_hn; 284 | } 285 | 286 | if (temp->n_minus != ground_node) 287 | { 288 | if (source_only == FALSE) 289 | temp->mptr_mm->val = temp->mptr_mm->val + two_c_hn; 290 | 291 | b_src_copy[temp->n_minus]->val = 292 | b_src_copy[temp->n_minus]->val - sval; 293 | /* 294 | b_source[temp->n_minus]->val = b_source[temp->n_minus]->val 295 | - sval; 296 | */ 297 | } 298 | 299 | temp_dev = temp_dev->next_dev; 300 | } 301 | 302 | } /* cap_trap */ 303 | 304 | 305 | void 306 | cap_tran_print(FILE *fp, double inc_rate, int prtype, device *temp_dev) 307 | { 308 | long plus, minus; 309 | double cap_val; 310 | double val; 311 | double plus_val, minus_val, pd_val, md_val; 312 | 313 | 314 | plus = ((dev_cap *) temp_dev->data)->n_plus; 315 | minus = ((dev_cap *) temp_dev->data)->n_minus; 316 | cap_val = ((dev_cap *) temp_dev->data)->val; 317 | 318 | 319 | if (prtype == VOLT) 320 | { 321 | plus_val = get_pr_val(inc_rate, plus, 0); 322 | minus_val = get_pr_val(inc_rate, minus, 0); 323 | fprintf(fp, out_format, plus_val - minus_val); 324 | return; 325 | } 326 | 327 | if (prtype == AMP) 328 | { 329 | pd_val = get_pr_val(inc_rate, plus, 1); 330 | md_val = get_pr_val(inc_rate, minus, 1); 331 | val = (pd_val - md_val)*cap_val; 332 | fprintf(fp, out_format, val); 333 | return; 334 | 335 | } 336 | 337 | } /* cap_tran_print */ 338 | 339 | -------------------------------------------------------------------------------- /vendor/jsim/device/device.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | device * 23 | find_dev(char *real_name, int type) 24 | { 25 | realname_name *temp_name; 26 | 27 | temp_name = search_realname(real_name); 28 | 29 | if (temp_name != NULL) 30 | switch (type) 31 | { 32 | case RESIS : 33 | return(search_name_dev(resis_array, resis_count, 34 | temp_name->name)); 35 | 36 | case CAP : 37 | return(search_name_dev(cap_array, cap_count, temp_name->name)); 38 | 39 | case INDUCT : 40 | return(search_name_dev(ind_array, ind_count, temp_name->name)); 41 | 42 | case V_SOURCE: 43 | case DC_V: 44 | case SIN_V: 45 | case PWL_V : 46 | case NOISE_V : 47 | 48 | return(search_name_dev(vsource_array, vsource_count, 49 | temp_name->name)); 50 | 51 | case I_SOURCE: 52 | case SIN_I: 53 | case PWL_I : 54 | case NOISE_I : 55 | return(search_name_dev(isource_array, isource_count, 56 | temp_name->name)); 57 | 58 | case JJ : 59 | return(search_name_dev(jj_array, jj_count, temp_name->name)); 60 | 61 | case MUTUAL_L : 62 | return(search_name_dev(mut_array, mut_count, 63 | temp_name->name)); 64 | 65 | case TRANSLINE : 66 | case TRAN_NO_LOSS : 67 | return(search_name_dev(xline_array, xline_count, 68 | temp_name->name)); 69 | 70 | } /* switch */ 71 | 72 | return(NULL); 73 | 74 | } /* find_dev */ 75 | 76 | 77 | device * 78 | add_dev(long name, int type, char *data) 79 | { 80 | device *temp; 81 | 82 | switch (type) 83 | { 84 | case RESIS : 85 | if (resis == NULL) 86 | { 87 | resis = (device *) mycalloc(1, sizeof(device)); 88 | resis_tail = resis; 89 | } 90 | else 91 | { 92 | resis_tail->next_dev = (device *) 93 | mycalloc(1, sizeof(device)); 94 | resis_tail = resis_tail->next_dev; 95 | } 96 | temp = resis_tail; 97 | resis_count++; 98 | break; 99 | 100 | case CAP : 101 | 102 | if (cap == NULL) 103 | { 104 | cap = (device *) mycalloc(1, sizeof(device)); 105 | cap_tail = cap; 106 | } 107 | else 108 | { 109 | cap_tail->next_dev = (device *) 110 | mycalloc(1, sizeof(device)); 111 | cap_tail = cap_tail->next_dev; 112 | } 113 | temp = cap_tail; 114 | cap_count++; 115 | break; 116 | 117 | case INDUCT : 118 | if (ind == NULL) 119 | { 120 | ind = (device *) mycalloc(1, sizeof(device)); 121 | ind_tail = ind; 122 | } 123 | else 124 | { 125 | ind_tail->next_dev = (device *) 126 | mycalloc(1, sizeof(device)); 127 | ind_tail = ind_tail->next_dev; 128 | } 129 | temp = ind_tail; 130 | ind_count++; 131 | break; 132 | 133 | case DC_V : 134 | case SIN_V : 135 | case PULSE_V : 136 | case PWL_V : 137 | case NOISE_V : 138 | 139 | case V_SOURCE : 140 | if (vsource == NULL) 141 | { 142 | vsource = (device *) mycalloc(1, sizeof(device)); 143 | vsource_tail = vsource; 144 | } 145 | else 146 | { 147 | vsource_tail->next_dev = (device *) 148 | mycalloc(1, sizeof(device)); 149 | vsource_tail = vsource_tail->next_dev; 150 | } 151 | temp = vsource_tail; 152 | vsource_count++; 153 | break; 154 | 155 | case SIN_I : 156 | case PULSE_I : 157 | case PWL_I : 158 | case NOISE_I : 159 | case I_SOURCE : 160 | 161 | if (isource == NULL) 162 | { 163 | isource = (device *) mycalloc(1, sizeof(device)); 164 | isource_tail = isource; 165 | } 166 | else 167 | { 168 | isource_tail->next_dev = (device *) 169 | mycalloc(1, sizeof(device)); 170 | isource_tail = isource_tail->next_dev; 171 | } 172 | temp = isource_tail; 173 | isource_count++; 174 | break; 175 | 176 | case JJ : 177 | 178 | if (jj == NULL) 179 | { 180 | jj = (device *) mycalloc(1, sizeof(device)); 181 | jj_tail = jj; 182 | } 183 | else 184 | { 185 | jj_tail->next_dev = (device *) 186 | mycalloc(1, sizeof(device)); 187 | jj_tail = jj_tail->next_dev; 188 | } 189 | temp = jj_tail; 190 | jj_count++; 191 | break; 192 | 193 | case MUTUAL_L : 194 | 195 | if (mut == NULL) 196 | { 197 | mut = (device *) mycalloc(1, sizeof(device)); 198 | mut_tail = mut; 199 | } 200 | else 201 | { 202 | mut_tail->next_dev = (device *) 203 | mycalloc(1, sizeof(device)); 204 | mut_tail = mut_tail->next_dev; 205 | } 206 | temp = mut_tail; 207 | mut_count++; 208 | break; 209 | 210 | case TRAN_NO_LOSS : 211 | 212 | if (xline == NULL) 213 | { 214 | xline = (device *) mycalloc(1, sizeof(device)); 215 | xline_tail = xline; 216 | } 217 | else 218 | { 219 | xline_tail->next_dev = (device *) 220 | mycalloc(1, sizeof(device)); 221 | xline_tail = xline_tail->next_dev; 222 | } 223 | temp = xline_tail; 224 | xline_count++; 225 | break; 226 | 227 | case SUB_C : 228 | 229 | if (sub_ckt == NULL) 230 | { 231 | sub_ckt = (device *) mycalloc(1, sizeof(device)); 232 | sub_ckt_tail = sub_ckt; 233 | } 234 | else 235 | { 236 | sub_ckt_tail->next_dev = (device *) 237 | mycalloc(1, sizeof(device)); 238 | sub_ckt_tail = sub_ckt_tail->next_dev; 239 | } 240 | temp = sub_ckt_tail; 241 | sub_ckt_count++; 242 | break; 243 | 244 | } /* switch */ 245 | 246 | temp->name = name; 247 | temp->type = type; 248 | temp->data = data; 249 | temp->next_dev = NULL; 250 | 251 | return(temp); 252 | 253 | } /* add_dev */ 254 | 255 | 256 | long 257 | add_realname(char *dev_name) 258 | { 259 | realname_name *temp_name; 260 | 261 | temp_name = (realname_name *) mycalloc(1, sizeof(realname_name)); 262 | temp_name->real_name = dev_name; 263 | dev_count++; 264 | temp_name->name = dev_count; 265 | temp_name->next_name = NULL; 266 | if (namelist == NULL) 267 | { 268 | namelist = temp_name; 269 | namelist_tail = temp_name; 270 | } 271 | else 272 | { 273 | namelist_tail->next_name = temp_name; 274 | namelist_tail = temp_name; 275 | } 276 | return(dev_count); 277 | 278 | } /* add_realname */ 279 | 280 | 281 | -------------------------------------------------------------------------------- /vendor/jsim/device/inductor.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | read_ind() 24 | { 25 | long name; 26 | int bad_dev = FALSE; 27 | 28 | intptr[0] = FALSE; 29 | dataptr[1] = 0.0; 30 | dataptr[2] = 1.0; 31 | 32 | read_error = read_long(nodeptr, "plus node", FALSE); 33 | read_error = read_long((nodeptr+1), "minus node", FALSE); 34 | read_error = read_double(dataptr, "inductance", FALSE); 35 | 36 | if (read_error != OK) 37 | { 38 | printf("## Error -- bad inductor definition\n"); 39 | no_go = TRUE; 40 | bad_dev = TRUE; 41 | } 42 | 43 | while ((read_error = read_string("")) == OK) 44 | switch (get_string_keyword(tempstring)) 45 | { 46 | case IC : 47 | read_error = read_double(dataptr+1, "initial condition", FALSE); 48 | break; 49 | 50 | case FCHECK : intptr[0] = TRUE; 51 | break; 52 | 53 | case FVALUE : 54 | read_error = read_double(dataptr+2, "proportion of phi 0", FALSE); 55 | break; 56 | 57 | default : 58 | printf("## Warning -- illegal keyword %s\n", tempstring); 59 | break; 60 | } 61 | 62 | if (bad_dev == FALSE) 63 | { 64 | if (current_sub_def == NULL) 65 | { 66 | name = add_realname(dev_name); 67 | ind_to_devlist(name, INDUCT, nodeptr, intptr, dataptr); 68 | } 69 | else 70 | ind_to_deftree(dev_name, INDUCT, nodeptr, intptr, dataptr); 71 | } 72 | 73 | } /* read_ind */ 74 | 75 | 76 | device * 77 | ind_to_devlist(long name, int type, long *nodeptr, long *intptr, 78 | double *dataptr) 79 | { 80 | int n_plus, n_minus, branch; 81 | branch_marker *bmarker; 82 | flux_check_list *temp_fcheck; 83 | device *temp_dev; 84 | 85 | switch (type) 86 | { 87 | case INDUCT : 88 | 89 | bmarker = add_bmarker(); 90 | n_plus = add_node(*nodeptr, name, type, PLUS_NODE, bmarker); 91 | n_minus = add_node(*(nodeptr+1), name, type, MINUS_NODE, 92 | bmarker); 93 | eqn_count++; 94 | branch = eqn_count; 95 | temp_dev = add_ind(name, dataptr[0], dataptr[1], n_plus, 96 | n_minus, branch, intptr[0], dataptr[2]); 97 | 98 | if (*intptr == TRUE) 99 | { 100 | if (fcheck_list == NULL) 101 | { 102 | temp_fcheck = (flux_check_list *) 103 | mycalloc(1, sizeof(flux_check_list)); 104 | temp_fcheck->flux_check = temp_dev; 105 | temp_fcheck->next_flux_check = NULL; 106 | fcheck_list = fcheck_tail = temp_fcheck; 107 | } 108 | else 109 | { 110 | temp_fcheck = (flux_check_list *) 111 | mycalloc(1, sizeof(flux_check_list)); 112 | temp_fcheck->flux_check = temp_dev; 113 | temp_fcheck->next_flux_check = NULL; 114 | fcheck_tail->next_flux_check = temp_fcheck; 115 | fcheck_tail = temp_fcheck; 116 | } 117 | } 118 | 119 | return(temp_dev); 120 | 121 | } /* switch */ 122 | 123 | return(NULL); 124 | 125 | } /* ind_to_devlist */ 126 | 127 | 128 | device * 129 | ind_to_deftree(char *dev_name, int type, long *nodeptr, long *intptr, 130 | double *dataptr) 131 | { 132 | int branch = 0; 133 | long name; 134 | 135 | name = (long) dev_name; 136 | 137 | switch (type) 138 | { 139 | case INDUCT : 140 | return(add_ind(name, dataptr[0], dataptr[1], *nodeptr, 141 | *(nodeptr+1), branch, intptr[0], dataptr[2])); 142 | 143 | } 144 | 145 | return(NULL); 146 | 147 | } /* ind_to_deftree */ 148 | 149 | 150 | device * 151 | indsub_to_devlist(char *dev_name, int type, char *data) 152 | { 153 | int n_plus, n_minus, branch; 154 | long name; 155 | branch_marker *bmarker; 156 | 157 | name = add_realname(combine_string(namestring, dev_name)); 158 | 159 | switch (type) 160 | { 161 | case INDUCT : 162 | 163 | bmarker = add_bmarker(); 164 | n_plus = getnode_subnode(((sub_ind *) data)->n_plus, 165 | ((sub_ind *) data)->p_node); 166 | n_plus = add_node(n_plus, name, type, PLUS_NODE, bmarker); 167 | n_minus = getnode_subnode(((sub_ind *) data)->n_minus, 168 | ((sub_ind *) data)->m_node); 169 | n_minus = add_node(n_minus, name, type, MINUS_NODE, 170 | bmarker); 171 | eqn_count++; 172 | branch = eqn_count; 173 | return(add_ind(name, ((sub_ind *) data)->val, 174 | ((sub_ind *) data)->ic, n_plus, n_minus, 175 | branch, ((sub_ind *) data)->fcheck, 176 | ((sub_ind *) data)->fvalue)); 177 | 178 | } /* switch */ 179 | 180 | return(NULL); 181 | 182 | } /* indsub_to_devlist */ 183 | 184 | 185 | device * 186 | add_ind(long name, double val, double ic, long n_plus, long n_minus, 187 | long branch, int fcheck, double fvalue) 188 | { 189 | char *data; 190 | dev_ind *temp; 191 | sub_ind *temp_sub; 192 | 193 | if (current_sub_def == NULL) 194 | { 195 | temp = (dev_ind *) mycalloc(1, sizeof(dev_ind)); 196 | 197 | temp->val = val; 198 | temp->ic = ic; 199 | temp->n_plus = n_plus; 200 | temp->n_minus = n_minus; 201 | temp->branch = branch; 202 | temp->fcheck = fcheck; 203 | temp->fvalue = fvalue; 204 | 205 | data = (char *) temp; 206 | return(add_dev(name, INDUCT, data)); 207 | } 208 | else 209 | { 210 | temp_sub = (sub_ind *) mycalloc(1, sizeof(sub_ind)); 211 | 212 | temp_sub->val = val; 213 | temp_sub->ic = ic; 214 | temp_sub->n_plus = n_plus; 215 | temp_sub->n_minus = n_minus; 216 | temp_sub->p_node = scan_node(n_plus); 217 | temp_sub->m_node = scan_node(n_minus); 218 | temp_sub->fcheck = fcheck; 219 | temp_sub->fvalue = fvalue; 220 | 221 | data = (char *) temp_sub; 222 | return(add_sub((char *) name, INDUCT, data)); 223 | } 224 | 225 | } /* add_ind */ 226 | 227 | 228 | void 229 | ind_matrix() 230 | { 231 | dev_ind *temp; 232 | m_data *temp_m; 233 | device *temp_dev; 234 | int exist; 235 | 236 | temp_dev = ind; 237 | 238 | while (temp_dev != NULL) 239 | { 240 | temp = (dev_ind *) temp_dev->data; 241 | 242 | temp->mptr_ii = add_i_j(A_matrix, 243 | temp->branch, temp->branch, &exist); 244 | temp->mptr_ii->type = ORIGINAL; 245 | 246 | if (temp->n_plus != GROUND) 247 | { 248 | temp_m = add_i_j(A_matrix, 249 | temp->n_plus, temp->branch, &exist); 250 | temp_m->val = 1.0; 251 | temp_m->type = CONST_ORIGINAL; 252 | 253 | temp_m = add_i_j(A_matrix, 254 | temp->branch, temp->n_plus, &exist); 255 | temp_m->val = 1.0; 256 | temp_m->type = CONST_ORIGINAL; 257 | 258 | } 259 | 260 | if (temp->n_minus != GROUND) 261 | { 262 | temp_m = add_i_j(A_matrix, 263 | temp->n_minus, temp->branch, &exist); 264 | temp_m->val = temp_m->val - 1.0; 265 | temp_m->type = CONST_ORIGINAL; 266 | 267 | temp_m = add_i_j(A_matrix, 268 | temp->branch, temp->n_minus, &exist); 269 | temp_m->val = temp_m->val - 1.0; 270 | temp_m->type = CONST_ORIGINAL; 271 | 272 | } 273 | 274 | x_unknown[temp->branch]->type = AMP_TIME; 275 | 276 | add_source(b_source, temp->branch); 277 | 278 | if (temp->n_plus == GROUND) temp->n_plus = ground_node; 279 | if (temp->n_minus == GROUND) temp->n_minus = ground_node; 280 | temp->fvalue = temp->fvalue*max_flux_step; 281 | 282 | temp_dev = temp_dev->next_dev; 283 | } 284 | 285 | } /* ind_matrix */ 286 | 287 | 288 | void 289 | ind_trap(int source_only, double *hptr) 290 | { 291 | dev_ind *temp; 292 | device *temp_dev; 293 | double xn1, xn1d, two_l_hn; 294 | 295 | temp_dev = ind; 296 | 297 | while (temp_dev != NULL) 298 | { 299 | temp = (dev_ind *) temp_dev->data; 300 | 301 | two_l_hn = (temp->val + temp->val)/(*hptr); 302 | 303 | xn1 = *(x_unk_copy[temp->branch]->xpast); 304 | xn1d = x_unk_copy[temp->branch]->xdpast; 305 | 306 | if (source_only == FALSE) 307 | temp->mptr_ii->val = temp->mptr_ii->val - two_l_hn; 308 | 309 | b_src_copy[temp->branch]->val = 310 | b_src_copy[temp->branch]->val 311 | - two_l_hn*xn1 - temp->val*xn1d; 312 | /* 313 | b_source[temp->branch]->val = b_source[temp->branch]->val 314 | - two_l_hn*xn1 - temp->val*xn1d; 315 | */ 316 | 317 | temp_dev = temp_dev->next_dev; 318 | } 319 | 320 | } /* ind_trap */ 321 | 322 | 323 | double 324 | ind_step_limit(double current_step) 325 | { 326 | flux_check_list *temp_fcheck; 327 | dev_ind *temp_ind; 328 | double smallest; 329 | double h; 330 | double delta_flux; 331 | 332 | smallest = 1.0e30; 333 | 334 | temp_fcheck = fcheck_list; 335 | 336 | while (temp_fcheck != NULL) 337 | { 338 | temp_ind = (dev_ind *) temp_fcheck->flux_check->data; 339 | 340 | delta_flux = myabs(x_unk_copy[temp_ind->branch]->xn - 341 | *(x_unk_copy[temp_ind->branch]->xpast)); 342 | 343 | delta_flux = delta_flux * temp_ind->val; 344 | 345 | if ((delta_flux > temp_ind->fvalue) || (delta_flux > 0.0)) 346 | h = current_step*(temp_ind->fvalue/delta_flux); 347 | else h = smallest; 348 | 349 | if (h < smallest) smallest = h; 350 | 351 | temp_fcheck = temp_fcheck->next_flux_check; 352 | 353 | } 354 | 355 | return(smallest); 356 | 357 | } /* ind_step_limit */ 358 | 359 | 360 | int 361 | ind_apriori_step_limit(double step, double *newstep) 362 | { 363 | dev_ind *temp_ind; 364 | flux_check_list *temp_flux; 365 | double h, smallest; 366 | double delta_flux; 367 | 368 | 369 | temp_flux = fcheck_list; 370 | smallest = step; 371 | 372 | while (temp_flux != NULL) 373 | { 374 | temp_ind = (dev_ind *) temp_flux->flux_check->data; 375 | 376 | delta_flux = (x_unk_copy[temp_ind->branch]->xdpast) * step; 377 | 378 | delta_flux = myabs(delta_flux * temp_ind->val); 379 | 380 | if (delta_flux > temp_ind->fvalue) 381 | { 382 | h = step * (temp_ind->fvalue/delta_flux); 383 | if (h < smallest) smallest = h; 384 | } 385 | 386 | temp_flux = temp_flux->next_flux_check; 387 | } 388 | 389 | if (smallest >= step) 390 | { 391 | *newstep = step; 392 | return(OK); 393 | } 394 | 395 | if (smallest + smallest >= step) 396 | { 397 | *newstep = smallest; 398 | return(TOO_BIG); 399 | } 400 | 401 | *newstep = 0.5*step; 402 | return(TOO_BIG); 403 | 404 | } /* ind_apriori_step_limit */ 405 | 406 | 407 | void 408 | ind_tran_print(FILE *fp, double inc_rate, int prtype, device *temp_dev) 409 | { 410 | long plus, minus, branch; 411 | double plus_val, minus_val, branch_val; 412 | 413 | plus = ((dev_ind *) temp_dev->data)->n_plus; 414 | minus = ((dev_ind *) temp_dev->data)->n_minus; 415 | branch = ((dev_ind *) temp_dev->data)->branch; 416 | 417 | if (prtype == VOLT) 418 | { 419 | plus_val = get_pr_val(inc_rate, plus, 0); 420 | minus_val = get_pr_val(inc_rate, minus, 0); 421 | fprintf(fp, out_format, plus_val - minus_val); 422 | return; 423 | } 424 | 425 | if (prtype == AMP) 426 | { 427 | branch_val = get_pr_val(inc_rate, branch, 0); 428 | fprintf(fp, out_format, branch_val); 429 | return; 430 | 431 | } 432 | 433 | } /* ind_tran_print */ 434 | 435 | -------------------------------------------------------------------------------- /vendor/jsim/device/isource.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | read_is() 24 | { 25 | long name; 26 | int ftype; 27 | char *temp_parm; 28 | dev_isource *temp_is; 29 | sub_isource *temp_subi; 30 | 31 | read_error = read_long(nodeptr, "plus node", FALSE); 32 | read_error = read_long((nodeptr+1), "minus node", FALSE); 33 | 34 | if (read_error == OK) 35 | temp_parm = read_function(&ftype); 36 | else temp_parm = NULL; 37 | 38 | if (temp_parm == NULL) 39 | { 40 | printf("## Error -- bad current source definition\n"); 41 | no_go = TRUE; 42 | return; 43 | } 44 | 45 | if (current_sub_def == NULL) 46 | { 47 | temp_is = (dev_isource *) mycalloc(1, sizeof(dev_isource)); 48 | temp_is->function = ftype; 49 | temp_is->function_parm = temp_parm; 50 | temp_is->n_plus = nodeptr[0]; 51 | temp_is->n_minus = nodeptr[1]; 52 | name = add_realname(dev_name); 53 | is_to_devlist(name, temp_is); 54 | } 55 | else 56 | { 57 | temp_subi = (sub_isource *) mycalloc(1, sizeof(sub_isource)); 58 | temp_subi->function = ftype; 59 | temp_subi->function_parm = temp_parm; 60 | temp_subi->n_plus = nodeptr[0]; 61 | temp_subi->n_minus = nodeptr[1]; 62 | temp_subi->p_node = scan_node(nodeptr[0]); 63 | temp_subi->m_node = scan_node(nodeptr[1]); 64 | is_to_deftree(dev_name, temp_subi); 65 | } 66 | 67 | } /* read_is */ 68 | 69 | 70 | device * 71 | is_to_devlist(long name, dev_isource *temp_is) 72 | { 73 | branch_marker *bmarker; 74 | 75 | bmarker = add_bmarker(); 76 | temp_is->n_plus = add_node(temp_is->n_plus, name, I_SOURCE, 77 | PLUS_NODE, bmarker); 78 | temp_is->n_minus = add_node(temp_is->n_minus, name, I_SOURCE, 79 | MINUS_NODE, bmarker); 80 | 81 | return(add_isource(name, (char *) temp_is)); 82 | 83 | } /* is_to_devlist */ 84 | 85 | 86 | device * 87 | is_to_deftree(char *dev_name, sub_isource *temp_subi) 88 | { 89 | long name; 90 | 91 | name = (long) dev_name; 92 | 93 | return(add_isource(name, (char *) temp_subi)); 94 | 95 | } /* is_to_deftree */ 96 | 97 | 98 | device * 99 | issub_to_devlist(char *dev_name, char *data) 100 | { 101 | int n_plus, n_minus; 102 | long name; 103 | branch_marker *bmarker; 104 | dev_isource *temp_is; 105 | 106 | name = add_realname(combine_string(namestring, dev_name)); 107 | 108 | 109 | bmarker = add_bmarker(); 110 | n_plus = getnode_subnode(((sub_isource *) data)->n_plus, 111 | ((sub_isource *) data)->p_node); 112 | n_plus = add_node(n_plus, name, I_SOURCE, PLUS_NODE, bmarker); 113 | n_minus = getnode_subnode(((sub_isource *) data)->n_minus, 114 | ((sub_isource *) data)->m_node); 115 | n_minus = add_node(n_minus, name, I_SOURCE, MINUS_NODE, bmarker); 116 | 117 | temp_is = (dev_isource *) mycalloc(1, sizeof(dev_isource)); 118 | 119 | temp_is->n_plus = n_plus; 120 | temp_is->n_minus = n_minus; 121 | temp_is->function = ((sub_isource *) data)->function; 122 | new_function(temp_is->function, &(temp_is->function_parm), 123 | ((sub_isource *) data)->function_parm); 124 | 125 | return(add_isource(name, (char *) temp_is)); 126 | 127 | } /* issub_to_devlist */ 128 | 129 | 130 | device * 131 | add_isource(long name, char *data) 132 | { 133 | if (current_sub_def == NULL) 134 | { 135 | return(add_dev(name, I_SOURCE, data)); 136 | } 137 | else 138 | { 139 | return(add_sub((char *) name, I_SOURCE, data)); 140 | } 141 | 142 | } /* add_isource */ 143 | 144 | 145 | void 146 | is_matrix() 147 | { 148 | device *temp_dev; 149 | dev_isource *temp_is; 150 | 151 | temp_dev = isource; 152 | 153 | while (temp_dev != NULL) 154 | { 155 | temp_is = (dev_isource *) temp_dev->data; 156 | 157 | if (temp_is->n_plus != GROUND) 158 | { 159 | /* 160 | if (x_unknown[temp_is->n_plus] == NULL) 161 | { 162 | add_unknown(x_unknown, temp_is->n_plus); 163 | x_unknown[temp_is->n_plus]->type = VOLT; 164 | } 165 | */ 166 | add_source(b_source, temp_is->n_plus); 167 | } 168 | 169 | if (temp_is->n_minus != GROUND) 170 | { 171 | /* 172 | if (x_unknown[temp_is->n_minus] == NULL) 173 | { 174 | add_unknown(x_unknown, temp_is->n_minus); 175 | x_unknown[temp_is->n_minus]->type = VOLT; 176 | } 177 | */ 178 | add_source(b_source, temp_is->n_minus); 179 | } 180 | 181 | if (temp_is->n_plus == GROUND) temp_is->n_plus = ground_node; 182 | if (temp_is->n_minus == GROUND) temp_is->n_minus = ground_node; 183 | 184 | temp_dev = temp_dev->next_dev; 185 | } 186 | 187 | } /* is_matrix */ 188 | 189 | 190 | void 191 | is_breakpoint() 192 | { 193 | device *temp_dev; 194 | dev_isource *temp_isource; 195 | 196 | temp_dev = isource; 197 | 198 | while (temp_dev != NULL) 199 | { 200 | temp_isource = (dev_isource *) temp_dev->data; 201 | 202 | func_breakpoint(temp_isource->function, 203 | temp_isource->function_parm, 204 | user_step, stop_time); 205 | 206 | temp_dev = temp_dev->next_dev; 207 | 208 | } /* while */ 209 | 210 | } /* is_breakpoint */ 211 | 212 | 213 | double 214 | is_eval(device *temp_dev, double time) 215 | { 216 | dev_isource *temp_is; 217 | 218 | temp_is = (dev_isource *) temp_dev->data; 219 | 220 | return(func_eval(temp_is->function, temp_is->function_parm, time)); 221 | 222 | } /* is_eval */ 223 | 224 | 225 | void 226 | is_advance(double *hptr) 227 | { 228 | device *temp_dev; 229 | dev_isource *temp_is; 230 | double temp_val; 231 | 232 | temp_dev = isource; 233 | 234 | while (temp_dev != NULL) 235 | { 236 | temp_is = (dev_isource *) temp_dev->data; 237 | 238 | temp_val = is_eval(temp_dev, *hptr + last_time); 239 | 240 | if (temp_is->n_plus != ground_node) 241 | b_src_copy[temp_is->n_plus]->val = 242 | b_src_copy[temp_is->n_plus]->val - temp_val; 243 | /* 244 | b_source[temp_is->n_plus]->val = 245 | b_source[temp_is->n_plus]->val - temp_val; 246 | */ 247 | 248 | if (temp_is->n_minus != ground_node) 249 | b_src_copy[temp_is->n_minus]->val = 250 | b_src_copy[temp_is->n_minus]->val + temp_val; 251 | /* 252 | b_source[temp_is->n_minus]->val = 253 | b_source[temp_is->n_minus]->val + temp_val; 254 | */ 255 | 256 | temp_dev = temp_dev->next_dev; 257 | 258 | } /* while */ 259 | 260 | } /* is_advance */ 261 | 262 | 263 | void 264 | is_tran_print(FILE *fp, double inc_rate, int prtype, device *temp_dev, 265 | double time) 266 | { 267 | long plus, minus; 268 | double plus_val, minus_val; 269 | 270 | plus = ((dev_isource *) temp_dev->data)->n_plus; 271 | minus = ((dev_isource *) temp_dev->data)->n_minus; 272 | 273 | if (prtype == VOLT) 274 | { 275 | plus_val = get_pr_val(inc_rate, plus, 0); 276 | minus_val = get_pr_val(inc_rate, minus, 0); 277 | fprintf(fp, out_format, plus_val - minus_val); 278 | return; 279 | } 280 | 281 | if (prtype == AMP) 282 | { 283 | fprintf(fp, out_format, is_eval(temp_dev, time)); 284 | return; 285 | } 286 | 287 | } /* is_tran_print */ 288 | 289 | -------------------------------------------------------------------------------- /vendor/jsim/device/mutual.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | read_mut() 24 | { 25 | long name; 26 | char *primary_name, *second_name; 27 | int bad_dev; 28 | 29 | bad_dev = FALSE; 30 | 31 | read_error = read_string("primary inductor"); 32 | if (read_error == OK) primary_name = new_string(tempstring); 33 | read_error = read_string("secondary inductor"); 34 | if (read_error == OK) second_name = new_string(tempstring); 35 | read_error = read_double(dataptr, "mutual coupling", FALSE); 36 | 37 | if (read_error != OK) 38 | { 39 | printf("## Error -- bad mutual inductance card\n"); 40 | no_go = TRUE; 41 | bad_dev = TRUE; 42 | } 43 | 44 | if (bad_dev == FALSE) 45 | { 46 | if (current_sub_def == NULL) 47 | { 48 | name = add_realname(dev_name); 49 | mut_to_devlist(name, MUTUAL_L, (long *) primary_name, 50 | (long *) second_name, dataptr); 51 | } 52 | else 53 | mut_to_deftree(dev_name, MUTUAL_L, (long *) primary_name, 54 | (long *) second_name, dataptr); 55 | } 56 | 57 | } /* read_mut */ 58 | 59 | 60 | device * 61 | mut_to_devlist(long name, int type, long *nodeptr, long *intptr, 62 | double *dataptr) 63 | { 64 | switch (type) 65 | { 66 | case MUTUAL_L : 67 | 68 | return(add_mut(name, *dataptr, (char *) nodeptr, 69 | (char *) intptr)); 70 | 71 | } 72 | 73 | return(NULL); 74 | 75 | } /* mut_to_devlist */ 76 | 77 | 78 | device * 79 | mut_to_deftree(char *dev_name, int type, long *nodeptr, long *intptr, 80 | double *dataptr) 81 | { 82 | long name; 83 | 84 | name = (long) dev_name; 85 | 86 | switch (type) 87 | { 88 | case MUTUAL_L : 89 | 90 | return(add_mut(name, *dataptr, (char *) nodeptr, 91 | (char *) intptr)); 92 | 93 | } 94 | 95 | return(NULL); 96 | 97 | } /* mut_to_deftree */ 98 | 99 | 100 | device * 101 | mutsub_to_devlist(char *dev_name, int type, char *data) 102 | { 103 | long name; 104 | char *primary_name, *second_name; 105 | 106 | name = add_realname(combine_string(namestring, dev_name)); 107 | 108 | switch (type) 109 | { 110 | case MUTUAL_L : 111 | 112 | primary_name = 113 | get_subdev_name(((sub_mut *) data)->primary_name); 114 | second_name = 115 | get_subdev_name(((sub_mut *) data)->second_name); 116 | return(add_mut(name, ((sub_mut *) data)->val, 117 | primary_name, second_name)); 118 | 119 | } /* switch */ 120 | 121 | return(NULL); 122 | 123 | } /* mutsub_to_devlist */ 124 | 125 | 126 | device * 127 | add_mut(long name, double val, char *primary_name, char *second_name) 128 | { 129 | char *data; 130 | dev_mut *temp; 131 | sub_mut *temp_sub; 132 | 133 | if (current_sub_def == NULL) 134 | { 135 | temp = (dev_mut *) mycalloc(1, sizeof(dev_mut)); 136 | 137 | temp->val = val; 138 | temp->primary_name = primary_name; 139 | temp->second_name = second_name; 140 | 141 | data = (char *) temp; 142 | return(add_dev(name, MUTUAL_L, data)); 143 | } 144 | else 145 | { 146 | temp_sub = (sub_mut *) mycalloc(1, sizeof(sub_mut)); 147 | 148 | temp_sub->val = val; 149 | temp_sub->primary_name = primary_name; 150 | temp_sub->second_name = second_name; 151 | 152 | data = (char *) temp_sub; 153 | return(add_sub((char *) name, MUTUAL_L, data)); 154 | } 155 | 156 | } /* add_mut */ 157 | 158 | 159 | void 160 | mut_dependent() 161 | { 162 | device *temp_dev, *prim_dev, *second_dev; 163 | dev_mut *temp_mut; 164 | realname_name *temp_name; 165 | 166 | temp_dev = mut; 167 | 168 | while (temp_dev != NULL) 169 | { 170 | temp_mut = (dev_mut *) temp_dev->data; 171 | 172 | prim_dev = find_dev(temp_mut->primary_name, INDUCT); 173 | second_dev = find_dev(temp_mut->second_name, INDUCT); 174 | 175 | if ((prim_dev == NULL) || (second_dev == NULL)) 176 | { 177 | temp_name = search_name(temp_dev->name); 178 | 179 | if (prim_dev == NULL) 180 | { 181 | printf("## Error -- %s for %s not defined\n", 182 | temp_mut->primary_name, temp_name->real_name); 183 | no_go = TRUE; 184 | } 185 | 186 | if (second_dev == NULL) 187 | { 188 | printf("## Error -- %s for %s not defined\n", 189 | temp_mut->second_name, temp_name->real_name); 190 | no_go = TRUE; 191 | } 192 | } 193 | else 194 | { 195 | 196 | temp_mut->n_primary = ((dev_ind *) (prim_dev->data))->branch; 197 | temp_mut->n_second = ((dev_ind *) (second_dev->data))->branch; 198 | temp_mut->val = sqrt((((dev_ind *) (prim_dev->data))->val)* 199 | (((dev_ind *) (second_dev->data))->val))* 200 | temp_mut->val; 201 | } 202 | 203 | temp_dev = temp_dev->next_dev; 204 | } 205 | 206 | } /* mut_dependent */ 207 | 208 | 209 | void 210 | mut_matrix() 211 | { 212 | dev_mut *temp; 213 | device *temp_dev; 214 | int exist; 215 | 216 | temp_dev = mut; 217 | 218 | while (temp_dev != NULL) 219 | { 220 | temp = (dev_mut *) temp_dev->data; 221 | 222 | temp->mptr_primary = add_i_j(A_matrix, temp->n_primary, 223 | temp->n_second, &exist); 224 | temp->mptr_primary->type = ORIGINAL; 225 | 226 | temp->mptr_second = add_i_j(A_matrix, temp->n_second, 227 | temp->n_primary, &exist); 228 | temp->mptr_second->type = ORIGINAL; 229 | 230 | temp_dev = temp_dev->next_dev; 231 | } 232 | 233 | } /* mut_matrix */ 234 | 235 | 236 | void 237 | mut_trap(int source_only, double *hptr) 238 | { 239 | dev_mut *temp; 240 | device *temp_dev; 241 | double xn1, xn1d, yn1, yn1d, two_l_hn; 242 | 243 | temp_dev = mut; 244 | 245 | while (temp_dev != NULL) 246 | { 247 | temp = (dev_mut *) temp_dev->data; 248 | 249 | two_l_hn = (temp->val + temp->val)/(*hptr); 250 | 251 | xn1 = *(x_unk_copy[temp->n_primary]->xpast); 252 | xn1d = x_unk_copy[temp->n_primary]->xdpast; 253 | 254 | yn1 = *(x_unk_copy[temp->n_second]->xpast); 255 | yn1d = x_unk_copy[temp->n_second]->xdpast; 256 | 257 | if (source_only == FALSE) 258 | { 259 | temp->mptr_primary->val = temp->mptr_primary->val - 260 | two_l_hn; 261 | 262 | temp->mptr_second->val = temp->mptr_second->val - 263 | two_l_hn; 264 | } 265 | 266 | b_src_copy[temp->n_primary]->val = 267 | b_src_copy[temp->n_primary]->val 268 | - two_l_hn*yn1 - temp->val*yn1d; 269 | 270 | b_src_copy[temp->n_second]->val = 271 | b_src_copy[temp->n_second]->val 272 | - two_l_hn*xn1 - temp->val*xn1d; 273 | /* 274 | b_source[temp->n_primary]->val = b_source[temp->n_primary]->val 275 | - two_l_hn*yn1 - temp->val*yn1d; 276 | 277 | b_source[temp->n_second]->val = b_source[temp->n_second]->val 278 | - two_l_hn*xn1 - temp->val*xn1d; 279 | */ 280 | 281 | temp_dev = temp_dev->next_dev; 282 | } 283 | 284 | } /* mut_trap */ 285 | -------------------------------------------------------------------------------- /vendor/jsim/device/picture.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | add_frame_point(frame *myframe, double time, double value) 24 | { 25 | double *temp_double; 26 | double delta_time; 27 | double last_val; 28 | int i, step_no; 29 | 30 | if (myframe->current_size == 0) 31 | { 32 | myframe->time_data[0] = time; 33 | myframe->value_data[0] = value; 34 | myframe->current_size = 1; 35 | return; 36 | } 37 | 38 | delta_time = time - myframe->time_data[myframe->current_size-1]; 39 | last_val = myframe->value_data[myframe->current_size-1]; 40 | 41 | if ((delta_time < myframe->nominal_step) && 42 | (myabs(value - last_val) < 43 | myframe->val_min + 44 | myframe->val_rel * mymin(myabs(last_val), myabs(value)))) 45 | return; 46 | 47 | if (delta_time >= myframe->interval) 48 | step_no = myframe->current_size; 49 | else 50 | { 51 | step_no = 0; 52 | while (time - myframe->time_data[step_no] >= myframe->interval) 53 | step_no++; 54 | 55 | } 56 | step_no--; 57 | 58 | if (step_no > 0) 59 | { 60 | for (i = step_no; i < myframe->current_size; i++) 61 | { 62 | myframe->time_data[i - step_no] = myframe->time_data[i]; 63 | myframe->value_data[i - step_no] = myframe->value_data[i]; 64 | } 65 | myframe->current_size = myframe->current_size - step_no; 66 | } 67 | 68 | if (myframe->current_size == myframe->size) 69 | { 70 | temp_double = (double *) 71 | mycalloc(myframe->size + myframe->unit_size, 72 | sizeof(double)); 73 | 74 | for (i = 0; i < myframe->size; i++) 75 | temp_double[i] = myframe->time_data[i]; 76 | 77 | myframe->time_data = temp_double; 78 | 79 | temp_double = (double *) 80 | mycalloc(myframe->size + myframe->unit_size, 81 | sizeof(double)); 82 | 83 | for (i = 0; i < myframe->size; i++) 84 | temp_double[i] = myframe->value_data[i]; 85 | 86 | myframe->value_data = temp_double; 87 | 88 | myframe->size = myframe->size + myframe->unit_size; 89 | } 90 | 91 | myframe->time_data[myframe->current_size] = time; 92 | myframe->value_data[myframe->current_size] = value; 93 | myframe->current_size++; 94 | 95 | } /* add_frame_point */ 96 | 97 | 98 | double 99 | delay_frame_point(frame *myframe, double time, int *index) 100 | { 101 | 102 | if (myframe->current_size == 0) 103 | { 104 | *index = -1; 105 | return(0.0); 106 | } 107 | 108 | time = time - myframe->interval; 109 | 110 | if (time < myframe->time_data[0]) 111 | { 112 | *index = -1; 113 | return(0.0); 114 | } 115 | 116 | if (time > myframe->time_data[myframe->current_size - 1]) 117 | { 118 | *index = -1; 119 | return(0.0); 120 | } 121 | 122 | if (myframe->current_size == 1) 123 | { 124 | *index = 0; 125 | return(myframe->value_data[myframe->current_size - 1]); 126 | } 127 | 128 | *index = 1; 129 | while (myframe->time_data[*index] < time) (*index)++; 130 | 131 | return(myframe->value_data[*index - 1] + 132 | (myframe->value_data[*index] - 133 | myframe->value_data[*index - 1]) * 134 | (time - myframe->time_data[*index - 1]) / 135 | (myframe->time_data[*index] - 136 | myframe->time_data[*index - 1])); 137 | 138 | 139 | } /* delay_frame_point */ 140 | 141 | 142 | -------------------------------------------------------------------------------- /vendor/jsim/device/resistor.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | read_resis() 24 | { 25 | long name; 26 | int bad_dev = FALSE; 27 | 28 | read_error = read_long(nodeptr, "plus node", FALSE); 29 | read_error = read_long((nodeptr+1), "minus node", FALSE); 30 | read_error = read_double(dataptr, "resistance", FALSE); 31 | 32 | if (read_error != OK) 33 | { 34 | printf("## Error -- bad resistor definition\n"); 35 | no_go = TRUE; 36 | bad_dev = TRUE; 37 | } 38 | 39 | if (bad_dev == FALSE) 40 | { 41 | if (current_sub_def == NULL) 42 | { 43 | name = add_realname(dev_name); 44 | resis_to_devlist(name, RESIS, nodeptr, dataptr); 45 | } 46 | else 47 | { 48 | resis_to_deftree(dev_name, RESIS, nodeptr, dataptr); 49 | } 50 | } 51 | 52 | } /* read_resis */ 53 | 54 | 55 | device * 56 | resis_to_devlist(long name, int type, long *nodeptr, double *dataptr) 57 | { 58 | int n_plus, n_minus; 59 | branch_marker *bmarker; 60 | 61 | switch (type) 62 | { 63 | case RESIS : 64 | bmarker = add_bmarker(); 65 | n_plus = add_node(*nodeptr, name, type, PLUS_NODE, bmarker); 66 | n_minus = add_node(*(nodeptr+1), name, type, MINUS_NODE, 67 | bmarker); 68 | return(add_resis(name, *dataptr, n_plus, n_minus)); 69 | 70 | } 71 | 72 | return(NULL); 73 | 74 | } /* resis_to_devlist */ 75 | 76 | 77 | device * 78 | resis_to_deftree(char *dev_name, int type, long *nodeptr, double *dataptr) 79 | { 80 | long name; 81 | 82 | name = (long) dev_name; 83 | 84 | switch (type) 85 | { 86 | case RESIS : 87 | return(add_resis(name, *dataptr, *nodeptr, *(nodeptr+1))); 88 | 89 | } 90 | 91 | return(NULL); 92 | 93 | } /* resis_to_deftree */ 94 | 95 | 96 | device * 97 | resissub_to_devlist(char *dev_name, int type, char *data) 98 | { 99 | int n_plus, n_minus; 100 | long name; 101 | branch_marker *bmarker; 102 | 103 | name = add_realname(combine_string(namestring, dev_name)); 104 | 105 | switch (type) 106 | { 107 | case RESIS : 108 | bmarker = add_bmarker(); 109 | n_plus = getnode_subnode(((sub_resis *) data)->n_plus, 110 | ((sub_resis *) data)->p_node); 111 | n_plus = add_node(n_plus, name, type, PLUS_NODE, bmarker); 112 | n_minus = getnode_subnode(((sub_resis *) data)->n_minus, 113 | ((sub_resis *) data)->m_node); 114 | n_minus = add_node(n_minus, name, type, MINUS_NODE, 115 | bmarker); 116 | return(add_resis(name, ((sub_resis *) data)->val, 117 | n_plus, n_minus)); 118 | 119 | } /* switch */ 120 | 121 | return(NULL); 122 | 123 | } /* resissub_to_devlist */ 124 | 125 | 126 | device * 127 | add_resis(long name, double val, long n_plus, long n_minus) 128 | { 129 | char *data; 130 | dev_resis *temp; 131 | sub_resis *temp_sub; 132 | 133 | if (current_sub_def == NULL) 134 | { 135 | temp = (dev_resis *) mycalloc(1, sizeof(dev_resis)); 136 | 137 | temp->val = val; 138 | temp->n_plus = n_plus; 139 | temp->n_minus = n_minus; 140 | 141 | data = (char *) temp; 142 | return(add_dev(name, RESIS, data)); 143 | } 144 | else 145 | { 146 | temp_sub = (sub_resis *) mycalloc(1, sizeof(sub_resis)); 147 | 148 | temp_sub->val = val; 149 | temp_sub->n_plus = n_plus; 150 | temp_sub->n_minus = n_minus; 151 | temp_sub->p_node = scan_node(n_plus); 152 | temp_sub->m_node = scan_node(n_minus); 153 | 154 | data = (char *) temp_sub; 155 | return(add_sub((char *) name, RESIS, data)); 156 | } 157 | 158 | } /* add_resis */ 159 | 160 | 161 | void 162 | resis_matrix() 163 | { 164 | dev_resis *temp; 165 | device *temp_dev; 166 | int exist; 167 | 168 | temp_dev = resis; 169 | 170 | while (temp_dev != NULL) 171 | { 172 | temp = (dev_resis *) temp_dev->data; 173 | 174 | if (temp->n_plus != GROUND) 175 | { 176 | temp->mptr_pp = add_i_j(A_matrix, temp->n_plus, 177 | temp->n_plus, &exist); 178 | temp->mptr_pp->type = ORIGINAL; 179 | 180 | /* 181 | if (x_unknown[temp->n_plus] == NULL) 182 | { 183 | add_unknown(x_unknown, temp->n_plus); 184 | x_unknown[temp->n_plus]->type = VOLT; 185 | } 186 | */ 187 | } 188 | 189 | if ((temp->n_plus != GROUND) && 190 | (temp->n_minus != GROUND)) 191 | { 192 | temp->mptr_pm = add_i_j(A_matrix, temp->n_plus, 193 | temp->n_minus, &exist); 194 | temp->mptr_pm->type = ORIGINAL; 195 | 196 | temp->mptr_mp = add_i_j(A_matrix, temp->n_minus, 197 | temp->n_plus, &exist); 198 | temp->mptr_mp->type = ORIGINAL; 199 | } 200 | 201 | if (temp->n_minus != GROUND) 202 | { 203 | temp->mptr_mm = add_i_j(A_matrix, temp->n_minus, 204 | temp->n_minus, &exist); 205 | temp->mptr_mm->type = ORIGINAL; 206 | 207 | /* 208 | if (x_unknown[temp->n_minus] == NULL) 209 | { 210 | add_unknown(x_unknown, temp->n_minus); 211 | x_unknown[temp->n_minus]->type = VOLT; 212 | } 213 | */ 214 | } 215 | 216 | if (temp->n_plus == GROUND) temp->n_plus = ground_node; 217 | if (temp->n_minus == GROUND) temp->n_minus = ground_node; 218 | 219 | temp_dev = temp_dev->next_dev; 220 | } 221 | 222 | } /* resis_matrix */ 223 | 224 | 225 | void 226 | resis_trap(int source_only) 227 | { 228 | dev_resis *temp; 229 | device *temp_dev; 230 | double g_val; 231 | 232 | if (source_only == TRUE) return; 233 | 234 | temp_dev = resis; 235 | 236 | while (temp_dev != NULL) 237 | { 238 | temp = (dev_resis *) temp_dev->data; 239 | 240 | g_val = 1.0/temp->val; 241 | 242 | if (temp->n_plus != ground_node) 243 | { 244 | temp->mptr_pp->val = temp->mptr_pp->val + g_val; 245 | } 246 | 247 | if ((temp->n_plus != ground_node) && 248 | (temp->n_minus != ground_node)) 249 | { 250 | 251 | temp->mptr_pm->val = temp->mptr_pm->val - g_val; 252 | 253 | temp->mptr_mp->val = temp->mptr_mp->val - g_val; 254 | 255 | } 256 | 257 | if (temp->n_minus != ground_node) 258 | { 259 | temp->mptr_mm->val = temp->mptr_mm->val + g_val; 260 | } 261 | 262 | temp_dev = temp_dev->next_dev; 263 | } 264 | 265 | } /* resis_trap */ 266 | 267 | 268 | void 269 | resis_tran_print(FILE *fp, double inc_rate, int prtype, device *temp_dev) 270 | { 271 | long plus, minus; 272 | double r_val; 273 | double val; 274 | double plus_val, minus_val; 275 | 276 | plus = ((dev_resis *) temp_dev->data)->n_plus; 277 | minus = ((dev_resis *) temp_dev->data)->n_minus; 278 | r_val = ((dev_resis *) temp_dev->data)->val; 279 | 280 | plus_val = get_pr_val(inc_rate, plus, 0); 281 | minus_val = get_pr_val(inc_rate, minus, 0); 282 | 283 | if (prtype == VOLT) 284 | { 285 | fprintf(fp, out_format, plus_val - minus_val); 286 | return; 287 | } 288 | 289 | if (prtype == AMP) 290 | { 291 | val = (plus_val - minus_val)/r_val; 292 | fprintf(fp, out_format, val); 293 | } /* switch */ 294 | 295 | } /* resis_tran_print */ 296 | 297 | -------------------------------------------------------------------------------- /vendor/jsim/device/vsource.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | void 23 | read_vs() 24 | { 25 | long name; 26 | int ftype; 27 | char *temp_parm; 28 | dev_vsource *temp_vs; 29 | sub_vsource *temp_subv; 30 | 31 | read_error = read_long(nodeptr, "plus node", FALSE); 32 | read_error = read_long((nodeptr+1), "minus node", FALSE); 33 | if (read_error == OK) 34 | temp_parm = read_function(&ftype); 35 | else temp_parm = NULL; 36 | 37 | if (temp_parm == NULL) 38 | { 39 | printf("## Error -- bad voltage source definition\n"); 40 | no_go = TRUE; 41 | return; 42 | } 43 | 44 | if (current_sub_def == NULL) 45 | { 46 | temp_vs = (dev_vsource *) mycalloc(1, sizeof(dev_vsource)); 47 | temp_vs->function = ftype; 48 | temp_vs->function_parm = temp_parm; 49 | temp_vs->n_plus = nodeptr[0]; 50 | temp_vs->n_minus = nodeptr[1]; 51 | name = add_realname(dev_name); 52 | vs_to_devlist(name, temp_vs); 53 | } 54 | else 55 | { 56 | temp_subv = (sub_vsource *) mycalloc(1, sizeof(sub_vsource)); 57 | temp_subv->function = ftype; 58 | temp_subv->function_parm = temp_parm; 59 | temp_subv->n_plus = nodeptr[0]; 60 | temp_subv->n_minus = nodeptr[1]; 61 | temp_subv->p_node = scan_node(nodeptr[0]); 62 | temp_subv->m_node = scan_node(nodeptr[1]); 63 | vs_to_deftree(dev_name, temp_subv); 64 | } 65 | 66 | } /* read_vs */ 67 | 68 | 69 | device * 70 | vs_to_devlist(long name, dev_vsource *temp_vs) 71 | { 72 | branch_marker *bmarker; 73 | 74 | bmarker = add_bmarker(); 75 | temp_vs->n_plus = add_node(temp_vs->n_plus, name, V_SOURCE, 76 | PLUS_NODE, bmarker); 77 | temp_vs->n_minus = add_node(temp_vs->n_minus, name, V_SOURCE, 78 | MINUS_NODE, bmarker); 79 | eqn_count++; 80 | temp_vs->branch = eqn_count; 81 | 82 | return(add_vsource(name, (char *) temp_vs)); 83 | 84 | } /* vs_to_devlist */ 85 | 86 | 87 | device * 88 | vs_to_deftree(char *dev_name, sub_vsource *temp_subv) 89 | { 90 | long name; 91 | 92 | name = (long) dev_name; 93 | 94 | return(add_vsource(name, (char *) temp_subv)); 95 | 96 | } /* vs_to_deftree */ 97 | 98 | 99 | device * 100 | vssub_to_devlist(char *dev_name, char *data) 101 | { 102 | int n_plus, n_minus, branch; 103 | long name; 104 | branch_marker *bmarker; 105 | dev_vsource *temp_vs; 106 | 107 | name = add_realname(combine_string(namestring, dev_name)); 108 | 109 | bmarker = add_bmarker(); 110 | n_plus = getnode_subnode(((sub_vsource *) data)->n_plus, 111 | ((sub_vsource *) data)->p_node); 112 | n_plus = add_node(n_plus, name, V_SOURCE, PLUS_NODE, bmarker); 113 | n_minus = getnode_subnode(((sub_vsource *) data)->n_minus, 114 | ((sub_vsource *) data)->m_node); 115 | n_minus = add_node(n_minus, name, V_SOURCE, MINUS_NODE, bmarker); 116 | eqn_count++; 117 | branch = eqn_count; 118 | 119 | temp_vs = (dev_vsource *) mycalloc(1, sizeof(dev_vsource)); 120 | 121 | temp_vs->n_plus = n_plus; 122 | temp_vs->n_minus = n_minus; 123 | temp_vs->branch = branch; 124 | temp_vs->function = ((sub_vsource *) data)->function; 125 | new_function(temp_vs->function, &(temp_vs->function_parm), 126 | ((sub_vsource *) data)->function_parm); 127 | 128 | return(add_vsource(name, (char *) temp_vs)); 129 | 130 | } /* vssub_to_devlist */ 131 | 132 | 133 | device * 134 | add_vsource(long name, char *data) 135 | { 136 | if (current_sub_def == NULL) 137 | { 138 | return(add_dev(name, V_SOURCE, data)); 139 | } 140 | else 141 | { 142 | return(add_sub((char *) name, V_SOURCE, data)); 143 | } 144 | 145 | } /* add_vsource */ 146 | 147 | 148 | void 149 | vs_matrix() 150 | { 151 | m_data *temp_m; 152 | device *temp_dev; 153 | dev_vsource *temp_vs; 154 | int exist; 155 | 156 | temp_dev = vsource; 157 | 158 | while (temp_dev != NULL) 159 | { 160 | temp_vs = (dev_vsource *) temp_dev->data; 161 | 162 | if (temp_vs->n_plus != GROUND) 163 | { 164 | temp_m = add_i_j(A_matrix, temp_vs->branch, 165 | temp_vs->n_plus, &exist); 166 | temp_m->val = 1.0; 167 | temp_m->type = CONST_ORIGINAL; 168 | 169 | temp_m = add_i_j(A_matrix, temp_vs->n_plus, 170 | temp_vs->branch, &exist); 171 | temp_m->val = 1.0; 172 | temp_m->type = CONST_ORIGINAL; 173 | 174 | /* 175 | if (x_unknown[temp_vs->n_plus] == NULL) 176 | { 177 | add_unknown(x_unknown, temp_vs->n_plus); 178 | x_unknown[temp_vs->n_plus]->type = VOLT; 179 | } 180 | */ 181 | } 182 | 183 | if (temp_vs->n_minus != GROUND) 184 | { 185 | temp_m = add_i_j(A_matrix, temp_vs->branch, 186 | temp_vs->n_minus, &exist); 187 | temp_m->val = 0.0 - 1.0; 188 | temp_m->type = CONST_ORIGINAL; 189 | 190 | temp_m = add_i_j(A_matrix, temp_vs->n_minus, 191 | temp_vs->branch, &exist); 192 | temp_m->val = 0.0 - 1.0; 193 | temp_m->type = CONST_ORIGINAL; 194 | 195 | /* 196 | if (x_unknown[temp_vs->n_minus] == NULL) 197 | { 198 | add_unknown(x_unknown, temp_vs->n_minus); 199 | x_unknown[temp_vs->n_minus]->type = VOLT; 200 | } 201 | */ 202 | } 203 | 204 | /* 205 | add_unknown(x_unknown, temp_vs->branch); 206 | */ 207 | x_unknown[temp_vs->branch]->type = AMP; 208 | 209 | add_source(b_source, temp_vs->branch); 210 | 211 | if (temp_vs->n_plus == GROUND) temp_vs->n_plus = ground_node; 212 | if (temp_vs->n_minus == GROUND) temp_vs->n_minus = ground_node; 213 | 214 | temp_dev = temp_dev->next_dev; 215 | } 216 | 217 | } /* vs_matrix */ 218 | 219 | 220 | void 221 | vs_breakpoint() 222 | { 223 | device *temp_dev; 224 | dev_vsource *temp_vsource; 225 | 226 | 227 | temp_dev = vsource; 228 | 229 | while (temp_dev != NULL) 230 | { 231 | 232 | temp_vsource = (dev_vsource *) temp_dev->data; 233 | 234 | 235 | func_breakpoint(temp_vsource->function, 236 | temp_vsource->function_parm, 237 | user_step, stop_time); 238 | 239 | temp_dev = temp_dev->next_dev; 240 | 241 | } /* while */ 242 | 243 | } /* vs_breakpoint */ 244 | 245 | 246 | double 247 | vs_eval(device *temp_dev, double time) 248 | { 249 | 250 | dev_vsource *temp_vs; 251 | 252 | temp_vs = (dev_vsource *) temp_dev->data; 253 | 254 | return(func_eval(temp_vs->function, temp_vs->function_parm, time)); 255 | 256 | } /* vs_eval */ 257 | 258 | 259 | void 260 | vs_advance(double *hptr) 261 | { 262 | 263 | device *temp_dev; 264 | dev_vsource *temp_vs; 265 | double temp_val; 266 | 267 | 268 | temp_dev = vsource; 269 | 270 | while (temp_dev != NULL) 271 | { 272 | temp_vs = (dev_vsource *) temp_dev->data; 273 | 274 | temp_val = vs_eval(temp_dev, *hptr + last_time); 275 | 276 | b_src_copy[temp_vs->branch]->val = 277 | b_src_copy[temp_vs->branch]->val + temp_val; 278 | /* 279 | b_source[temp_vs->branch]->val = 280 | b_source[temp_vs->branch]->val + temp_val; 281 | */ 282 | 283 | temp_dev = temp_dev->next_dev; 284 | 285 | } /* while */ 286 | 287 | } /* vs_advance */ 288 | 289 | 290 | void 291 | vs_tran_print(FILE *fp, double inc_rate, int prtype, device *temp_dev) 292 | { 293 | long plus, minus, branch; 294 | double plus_val, minus_val, branch_val; 295 | 296 | plus = ((dev_vsource *) temp_dev->data)->n_plus; 297 | minus = ((dev_vsource *) temp_dev->data)->n_minus; 298 | branch = ((dev_vsource *) temp_dev->data)->branch; 299 | 300 | if (prtype == VOLT) 301 | { 302 | plus_val = get_pr_val(inc_rate, plus, 0); 303 | minus_val = get_pr_val(inc_rate, minus, 0); 304 | fprintf(fp, out_format, plus_val - minus_val); 305 | return; 306 | } 307 | 308 | if (prtype == AMP) 309 | { 310 | branch_val = get_pr_val(inc_rate, branch, 0); 311 | fprintf(fp, out_format, branch_val); 312 | return; 313 | } 314 | 315 | } /* vs_tran_print */ 316 | 317 | -------------------------------------------------------------------------------- /vendor/jsim/examples/cntr: -------------------------------------------------------------------------------- 1 | * 3 stage counter 2 | * 3 | * 4 | .tran 1p 500p 5 | .subckt count 1 4 5 10 11 6 | * 7 | * Two junction SQUID flip-flop 8 | * 9 | b1 3 0 jj1 area=.9 10 | b2 5 0 jj1 11 | c1 4 0 3.5p 12 | r1 3 6 2 13 | r2 5 7 5 14 | l1 3 4 6.3p 15 | l2 4 5 5.7p 16 | l3 1 2 6.3p 17 | l4 2 0 5.7p 18 | l5 6 0 1.2p 19 | l6 7 0 2p 20 | k1 l1 l3 .99 21 | k2 l2 l4 .99 22 | .ends count 23 | * 24 | .subckt pgen 1 4 5 10 11 25 | * 26 | * Two junction SQUID pulse gen 27 | * 28 | b1 3 0 jj1 29 | b2 5 0 jj1 30 | c1 4 0 3.5p 31 | r1 3 6 1.5 32 | r2 5 7 5 33 | l1 3 4 6p 34 | l2 4 5 6p 35 | l3 1 2 6p 36 | l4 2 0 6p 37 | l5 6 0 1.2p 38 | l6 7 0 2p 39 | k1 l1 l3 .99 40 | k2 l2 l4 .99 41 | .ends pgen 42 | * 43 | * 44 | * First stage for SFQ pulse generation only 45 | * 46 | x1 pgen 1 2 3 100 101 47 | x2 count 5 6 7 200 201 48 | x3 count 9 10 11 300 301 49 | x4 count 13 14 15 400 401 50 | x5 count 17 18 19 500 501 51 | * 52 | r1 33 2 50 53 | r2 31 6 50 54 | r3 31 10 50 55 | r4 31 14 50 56 | r5 31 18 50 57 | * 58 | r6 34 1 50 59 | r7 32 1 80 60 | r8 30 5 50 61 | r9 30 9 50 62 | r10 30 13 50 63 | r11 30 17 50 64 | * 65 | r12 3 4 .25 66 | r13 7 8 .25 67 | r14 11 12 .25 68 | r15 15 16 .25 69 | r16 19 20 3.5 70 | l1 4 6 2.0p 71 | l2 8 10 2.0p 72 | l3 12 14 2.0p 73 | l4 16 18 2.0p 74 | l5 20 0 2p 75 | * 76 | r17 3 0 6 77 | * 78 | * flux bias 79 | v1 30 0 pulse(0 5.5m 10p 30p 0p 500p 1500p) 80 | * gate bias 81 | v2 31 0 pulse(0 15.5m 0p 20p 0p 500p 1500p) 82 | * 83 | * flux bias first stage 84 | v3 32 0 pwl (0 0 70p 0 85 | + 75p 15m 90p 15m 100p -15m 115p -15m 86 | + 125p 15m 140p 15m 150p -15m 165p -15m 87 | + 175p 15m 190p 15m 200p -15m 215p -15m 88 | + 225p 15m 240p 15m 250p -15m 265p -15m 89 | + 275p 15m 290p 15m 300p -15m 315p -15m 90 | + 325p 15m 340p 15m 350p -15m 365p -15m 91 | + 375p 15m 390p 15m 400p -15m 415p -15m 92 | + 425p 15m 440p 15m 450p -15m 465p -15m 475p 15m) 93 | * 94 | * gate bias first stage 95 | v4 33 0 pulse(0 15m 0p 20p 0p 500p 1500p) 96 | * 97 | * flux offset first stage 98 | v5 34 0 pulse(0 4m 10p 30p 0p 500p 1500p) 99 | * 100 | *Nb 1000 A/cm2 area = 30 square microns 101 | .model jj1 jj(rtype=1,cct=1,icon=10m,vg=2.8m,delv=0.08m, 102 | + icrit=0.3m,r0=100,rn=5.4902,cap=1.14195p) 103 | * 104 | .print nodev 3 0 105 | -------------------------------------------------------------------------------- /vendor/jsim/examples/jjiv: -------------------------------------------------------------------------------- 1 | * IV curve 2 | * 3 | b1 1 0 jj1 4 | v1 2 0 pwl(0 0 20n 70m 40n 0 50n 0) 5 | r1 2 1 100 6 | * 7 | * 8 | *Nb 1000 A/cm2 area = 30 square microns 9 | .model jj1 jj(rtype=4,cct=1,icon=10m,vg=2.8m,delv=.1m, 10 | + icrit=0.3m,r0=10,rn=5.4902,cap=1.14195p) 11 | .tran 5p 50n 12 | .file out1 13 | .print nodev 1 0 14 | .print devi v1 15 | .options reltol=.001 maxphistep=.3 16 | .end 17 | -------------------------------------------------------------------------------- /vendor/jsim/examples/jtl: -------------------------------------------------------------------------------- 1 | * Josephson transmission line 2 | b1 1 0 jj1 3 | b2 2 0 jj1 4 | b3 3 0 jj1 5 | b4 4 0 jj1 6 | b5 5 0 jj1 7 | b6 6 0 jj1 8 | b7 7 0 jj1 9 | b8 8 0 jj1 10 | b9 9 0 jj1 11 | b10 10 0 jj1 12 | l1 1 2 3.295p 13 | l2 2 3 3.295p 14 | l3 3 4 3.295p 15 | l4 4 5 3.295p 16 | l5 5 6 3.295p 17 | l6 6 7 3.295p 18 | l7 7 8 3.295p 19 | l8 8 9 3.295p 20 | l9 9 10 3.295p 21 | i1 0 1 pulse(0 .25m 0 20p 20p 1n 2n) 22 | .model jj1 jj(rtype=1 icrit=.1m r0=1 rn=1 cap=3.295p) 23 | .tran 1p 500p 24 | *.file out1 25 | .print nodev 1 0 26 | .print nodev 2 0 27 | -------------------------------------------------------------------------------- /vendor/jsim/include/global.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | FILE *fileptr[MAXFILE+1]; 19 | FILE *current_fp; 20 | int file_count; 21 | 22 | long lu_opcount; 23 | 24 | node_to_eqn *node_map[RANGE + 1]; 25 | long ground_node; 26 | long eqn_count; 27 | long phi_start; 28 | long phi_end; 29 | long phi_count; 30 | long node_count; 31 | long subnode_count; 32 | long *node_array; 33 | long *eqn_array; 34 | 35 | matrix *A_matrix, my_matrix; 36 | unknown *x_unknown; 37 | unknown *x_unk_copy; 38 | source *b_source; 39 | source *b_src_copy; 40 | double last_time; 41 | double stop_time; 42 | double user_step; 43 | double user_pr_step; 44 | double start_pr_time; 45 | double last_pr_time; 46 | 47 | model jsim_model; 48 | model jsim_model_tail; 49 | long *jsim_model_array; 50 | int mod_count; 51 | 52 | double vtran_min; 53 | double vtran_rel; 54 | double itran_min; 55 | double itran_rel; 56 | double error_tolerance; 57 | 58 | double max_phi_step; 59 | double phi_min; 60 | double phi_rel; 61 | double phi_quit; 62 | 63 | double max_flux_step; 64 | 65 | int nu_digit; 66 | char out_format[20]; 67 | 68 | double vs_min_inc; 69 | double vs_max_inc; 70 | double is_min_inc; 71 | double is_max_inc; 72 | int nu_min_sample; 73 | int nu_segment; 74 | 75 | double vn_guess_min; 76 | 77 | int no_truncation_error; 78 | int no_flux_control; 79 | 80 | long lu_count; 81 | long solve_count; 82 | long last_solve_count; 83 | 84 | printdata *print_list, *print_tail; 85 | 86 | device *resis, *resis_tail; 87 | long resis_count; 88 | long *resis_array; 89 | 90 | device *cap, *cap_tail; 91 | long cap_count; 92 | long *cap_array; 93 | 94 | device *ind, *ind_tail; 95 | long ind_count; 96 | long *ind_array; 97 | 98 | flux_check_list *fcheck_list, *fcheck_tail; 99 | 100 | device *jj, *jj_tail; 101 | long jj_count; 102 | long *jj_array; 103 | 104 | device *vsource, *vsource_tail; 105 | long vsource_count; 106 | long *vsource_array; 107 | 108 | device *isource, *isource_tail; 109 | long isource_count; 110 | long *isource_array; 111 | 112 | device *mut, *mut_tail; 113 | long mut_count; 114 | long *mut_array; 115 | 116 | device *xline, *xline_tail; 117 | long xline_count; 118 | long *xline_array; 119 | 120 | device *sub_ckt, *sub_ckt_tail; 121 | long sub_ckt_count; 122 | long *sub_ckt_array; 123 | 124 | sub_def *sub_def_tree, *sub_def_tail; 125 | long sub_def_count; 126 | long *sub_def_array; 127 | sub_def *current_sub_def; 128 | 129 | realname_name *namelist, *namelist_tail; 130 | long dev_count; 131 | long *realname_array, *name_array; 132 | 133 | 134 | int no_go; 135 | int warned; 136 | int igwarn_no_go; 137 | int jsim_dbg; 138 | int jsim_raw; 139 | int jsim_mout; 140 | 141 | int read_error; 142 | char *dev_name; 143 | char linesave[50000]; 144 | char linesave_lower[50000]; 145 | char *line; 146 | char namestring[200]; 147 | char tempstring[50000]; 148 | double dataptr[20000]; 149 | long nodeptr[100]; 150 | long intptr[100]; 151 | char *filename[MAXFILE]; 152 | 153 | char *mfilename; 154 | FILE *mfile; 155 | 156 | double hptr[STEPSAVE+1]; 157 | 158 | int bkpoint_count; 159 | double *bkpoint_time, *bkpoint_step; 160 | -------------------------------------------------------------------------------- /vendor/jsim/include/setup.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #ifndef __SETUP_H__ 19 | #define __SETUP_H__ 20 | 21 | 22 | #define MAX_INCLUDE_FILES 16 23 | 24 | 25 | void init_global(); 26 | void init_default_global(); 27 | void init_dev_global(); 28 | void init_A(matrix *A); 29 | void init_source(source *b); 30 | void init_unknown(unknown *x); 31 | void init_unk_copy(unknown *x, unknown *xc); 32 | void init_b_src_copy(source *b, source *bc); 33 | void init_node_map(); 34 | 35 | 36 | extern FILE *fp; 37 | void read_includefile(); 38 | void read_deck(); 39 | char * datestring(); 40 | 41 | 42 | 43 | extern int current_input_file; 44 | 45 | typedef struct { 46 | const char *filename; 47 | int line_number; 48 | FILE *fp; 49 | } included_file; 50 | 51 | extern included_file included_files[MAX_INCLUDE_FILES]; 52 | 53 | 54 | void print_file_stack(); 55 | int add_input_file(char *filename, FILE *fp); 56 | int open_input_file(char *filename); 57 | void read_includefile(); 58 | void read_option(); 59 | void process_deck(); 60 | void get_arrays(); 61 | void do_dependent(); 62 | void get_model(); 63 | void free_space(); 64 | void setup_device(); 65 | void setup_x_unknown(); 66 | void setup_A_matrix(); 67 | void setup_matrix(); 68 | void get_breakpoint(); 69 | void topology_check(); 70 | void deckerror_check(); 71 | void print_node_map(); 72 | void print_dev_array(long *dev_array, long dev_count); 73 | void print_devlist(); 74 | void print_deftree(sub_def *the_sub_def); 75 | void myprint_deftree(sub_def *the_sub_def, FILE *fp); 76 | void print_modlist(); 77 | void print_realname_name(); 78 | 79 | #endif /* __SETUP_H__ */ 80 | 81 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-COPYRIGHT: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * jsim_n 3/8/95 * 3 | * stochastic extension of jsim. * 4 | * (c)British Crown copyright January 1997/DERA. * 5 | * Permission to use, copy, modify, and distribute this software * 6 | * for any purpose without fee is hereby granted, provided that the * 7 | * above copyright notice appears in all copies. The copyright * 8 | * holders make no representations about the suitability of this * 9 | * software for any purpose. It is provided "as is" without express * 10 | * or implied warranty. No liability is accepted by the copyright * 11 | * holder for any use made of this software * 12 | **********************************************************************/ 13 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-README: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * jsim_n 3/8/95 * 3 | * stochastic extension of jsim. * 4 | * * 5 | * Modifications by J. Satchell (satchell@dra.hmg.gb) * 6 | * Files that have been altered have "_n" at the end of the first * 7 | * component of their names. The modifications, the makefile, this * 8 | * README, the documentation file noise.ms, the awk script noise.awkf * 9 | * and the contents of the tests directory are all covered by the * 10 | * following copyright * 11 | * * 12 | * (c) British Crown copyright January 1997/DERA. * 13 | * Permission to use, copy, modify, and distribute this software * 14 | * and documentation for any purpose without fee is hereby granted, * 15 | * provided that the above copyright notice appears in all copies * 16 | * The copyright holders make no representations about the * 17 | * suitability of this software for any purpose. It is provided * 18 | * "as is" without express or implied warranty. No liability is * 19 | * accepted by the copyright holder for any use made of this * 20 | * software * 21 | * * 22 | * See below for revised make instructions * 23 | * * 24 | **********************************************************************/ 25 | /** _n **/ 26 | See the original README file, which I have renamed README.old. 27 | I don't think I have anything to add to it, except I have removed the dos 28 | make files as they would need modifications that I am not competent to make. 29 | 30 | I have made a dumb makefile, which does not need the subsidiary ones in 31 | the subdirectories. It also doesn't bother with ar or ranlib. 32 | 33 | So now to implement, just edit makefile, (e.g change cc to gcc). 34 | If you are on a machine which does not support random() in its c library, 35 | set -DNORANDOM, and the horrible function rand() will be used. This is 36 | a low quality random number generator, with a spectrum which is 37 | coloured, but is supported on almost all machines. Alternatively 38 | see if your system supports srand48/drand48, and edit the source code 39 | to use those instead. 40 | 41 | To improve the interactive feel of my graphics I have added 42 | extra flushing statements, which will incur a small IO 43 | overhead. If this bothers you, comment out the calls to fflush 44 | in file jsimtxt/tran_n.c 45 | 46 | An awk script has been provided which adds noise to circuit, 47 | by including noise current source across every resistor. 48 | To use it on a file circuit.js you could try 49 | 50 | awk -f noise.awkf temperature=77.36 < circuit.js | jsim_n 51 | 52 | As far as I know any of awk, nawk and gawk are OK. If you are 53 | using DOS/Windoze, you are stuck, unless there is a DOS awk 54 | implementation available somewhere on the net. The script is simple 55 | enough that it could be emulated by some other programme if need be. 56 | 57 | Resistors whose names start with Z are left alone, so you can 58 | add noise free bias networks, output filters and the like. 59 | 60 | There are some tests in the jsim_n-tests subdirectory. 61 | 62 | 63 | Julian Satchell (satchell@dra.hmg.gb) (+44) 1684 895003 64 | 65 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(jsim_n_test C) 4 | 5 | 6 | include(CheckFunctionExists) 7 | 8 | CHECK_FUNCTION_EXISTS(pow NOT_NEED_LIBM) 9 | if(NOT_NEED_LIBM) 10 | set(LIB_MATH "") 11 | else() 12 | set(CMAKE_REQUIRED_LIBRARIES m) 13 | CHECK_FUNCTION_EXISTS(pow HAVE_LIBM) 14 | if(HAVE_LIBM) 15 | set(LIB_MATH m) 16 | else() 17 | message(FATAL_ERROR "No libm found for math support") 18 | endif() 19 | endif() 20 | 21 | if (WIN32) 22 | # Win32 needs to know to define M_PI 23 | add_definitions(-D_USE_MATH_DEFINES) 24 | endif (WIN32) 25 | 26 | add_executable(ah 27 | ah.c 28 | ) 29 | 30 | target_link_libraries(ah 31 | PUBLIC 32 | ${LIB_MATH} 33 | ) 34 | 35 | add_executable(rt 36 | rt.c 37 | ) 38 | 39 | target_link_libraries(rt 40 | PUBLIC 41 | ${LIB_MATH} 42 | ) 43 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/README: -------------------------------------------------------------------------------- 1 | This directory contains the test suite I use to check the performance. 2 | The shell script dotest will run the tests. Tests with an n in the name 3 | of the file involve noise, so the results will vary from run to run. By 4 | default dotest performs these 16 times, and list of values is printed. 5 | 6 | For convenience, two small c programmes are included. ah.c calculates 7 | the voltage expected on an RSJ junction using the Ambegoakar-Halperin 8 | solution. rt.c checks the properties of one of the system's random 9 | number generators. You can set which one to use by defining an appropriate 10 | symbol at compilation. See the source for details. 11 | 12 | ********************************************************************** 13 | * (c) British Crown copyright January 1997/ DERA. * 14 | * Permission to use, copy, modify, and distribute this software * 15 | * and documentation for any purpose without fee is hereby granted, * 16 | * provided that the above copyright notice appears in all copies * 17 | * The copyright holders make no representations about the * 18 | * suitability of this software for any purpose. It is provided * 19 | * "as is" without express or implied warranty. No liability is * 20 | * by the copyright holder for any use made of this software * 21 | ********************************************************************** -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/ah.c: -------------------------------------------------------------------------------- 1 | /* calculate a-h solution. Likharev 116 */ 2 | 3 | #include 4 | #include 5 | 6 | double modb(double z); 7 | 8 | double modb(double z) 9 | /* modified bessel fn I0 */ 10 | 11 | { 12 | double a,t,p,t2,t4,i2,i4; 13 | t = z / 3.75; 14 | if (z>3.75) 15 | { 16 | i2=1.0/t/t; i4=i2*i2; 17 | p = 0.39894228 + 0.01328592/t + 0.00225319*i2 - 0.000157565*i2/t 18 | + 0.00916281 *i4 - 0.02057706*i4/t 19 | + 0.02635537 *i4 *i2 - 0.01647633*i4*i2/t 20 | + 0.00392377*i4*i4; 21 | a = exp (z) * p /sqrt(z); 22 | } 23 | else 24 | { 25 | t2 = t*t; t4 = t2 *t2; 26 | a = 1 +3.5156229 *t2 + 3.0899224*t4 + 1.2067492*t4*t2 27 | + 0.2659732*t4*t4 + 0.0360768*t4*t4*t2 28 | + 0.0045813*t4*t4*t4 ; 29 | } 30 | return a; 31 | } 32 | 33 | int main(int argc, char *argv[]) 34 | 35 | { 36 | double v, integral, dx, x, y ,gam ,i; 37 | int j,jmax; 38 | printf("Enter current, gamma \n"); 39 | scanf("%lF %lF", &i, &gam); 40 | jmax = 100 + 60/gam; 41 | integral = 0; 42 | dx = M_PI/jmax/2; 43 | for (j=0; j testlog 6 | 7 | Machine Compiler O/S Time 8 | Decstation 5000/33 gcc 2.7.2 Ultrix 4.2a 127 9 | Dell 486/66 gcc 2.7.2 Linux 2.0 180 10 | MacBook Pro 2.8Ghz I7 clang-802.0.42 OSX 10.12.5 1.2s 11 | 12 | Please mail me other exciting results 13 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/dotest: -------------------------------------------------------------------------------- 1 | #!/bin/csh 2 | # 3 | # tests performance of jsim or near relation. 4 | # 5 | set VICTIM = jsim_n 6 | set iter = 16 7 | # number of iterations for random averages 8 | # remove old test detritus 9 | rm -f /tmp/jsimtest 10 | 11 | if ($#argv == 1 ) then 12 | set TESTS = test${argv[1]}.js 13 | else 14 | set TESTS = test*.js 15 | endif 16 | 17 | foreach i ( ${TESTS} ) 18 | echo ${i} 19 | grep '^\*WHY' ${i} 20 | if ($i =~ *n.js ) then 21 | set j = $iter 22 | while ( $j > 0 ) 23 | ${VICTIM} < $i > /tmp/jsimtest 24 | set ans = `grep "^[0-9]" /tmp/jsimtest` 25 | echo $ans[3] 26 | @ j = $j - 1 27 | end 28 | else 29 | ${VICTIM} < $i > /tmp/jsimtest 30 | grep '^[0-9]' /tmp/jsimtest 31 | endif 32 | grep '^\*REF' /tmp/jsimtest 33 | echo ' ' 34 | end 35 | rm -f /tmp/jsimtest 36 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/rt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Define generator and scaling factor*/ 6 | #if defined USERAND 7 | #define RANDGEN rand() /2048.0/1024.0/1024.0 8 | #elif defined USERAND48 9 | #define RANDGEN lrand48()/2048.0/1024.0/1024.0 10 | #else 11 | #define RANDGEN random()/2048.0/1024.0/1024.0 12 | #endif 13 | 14 | int main(void) 15 | { 16 | double x,vals[128],corr[128],d[128],mom[4],dmom[3]; 17 | int i,j,k,n; 18 | for (i=0;i<128;i++) 19 | { 20 | vals[i] = RANDGEN ; 21 | corr[i] = 0.0; d[i] = 0.0; 22 | } 23 | n= 1000000; 24 | for (k=0;k0;j--) 28 | vals[j] = vals[j-1]; 29 | vals[0] = x; mom[0]=mom[0]+x/n; 30 | mom[1]=mom[1]+x*x/n;mom[2]=mom[2]+x*x*x/n;mom[3]=mom[3]+x*x*x*x/n; 31 | dmom[0]=mom[1]+(1-x)*(1-x)/n;dmom[1]=mom[2]+(1-x)*(1-x)*(1-x)/n; 32 | dmom[2]=mom[3]+(1-x)*(1-x)*(1-x)*(1-x)/n; 33 | i = floor(x*128.0); 34 | d[i] = 128.0/n + d[i]; 35 | for(j=0;j<128;j++) 36 | corr[j] = corr[j] + x*vals[j]; 37 | } 38 | printf(" %d numbers generated. SEM +/- %8.5f \n",n,sqrt(1.0/12.0/n)); 39 | printf("Moments %8.5f %8.5f %8.5f %8.5f \n",mom[0],mom[1],mom[2],mom[3]); 40 | printf("Complement Moments %8.5f %8.5f %8.5f \n",dmom[0],dmom[1],dmom[2]); 41 | for (j=0;j<16;j++) 42 | { 43 | for (i=0;i<8;i++) 44 | printf("%8.4f ",corr[8*j+i]/n); 45 | printf("\n"); 46 | } 47 | 48 | printf("\nDistribution \n"); 49 | for (j=0;j<16;j++) 50 | { 51 | for (i=0;i<8;i++) 52 | printf("%8.4f ",d[8*j+i]); 53 | printf("\n"); 54 | } 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test0.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY OHMS LAW 3 | I0 0 1 PWL(0 0 20ps 100UA) 4 | R2 1 0 1.0 5 | .PRINT DEVI I0 6 | .PRINT DEVV R2 7 | 8 | .TRAN 100p 100p 50p 9 | *REF 5.000e-11 1.000e-04 1.000e-04 10 | 11 | 12 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test1.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY Capacitor charging 3 | I0 0 1 PULSE(0 1MA 20p 5p 5p 5P 200P) 4 | C2 1 0 1.0pf 5 | R1 1 0 100MEG 6 | .PRINT DEVI I0 7 | .PRINT DEVV C2 8 | 9 | .TRAN 100p 100p 50p 10 | *REF 5.000e-11 0.000e-04 1.000e-02 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test10n.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at 0.8*IC TEMP=119 , avg voltage, beta=4, gam = 0.2 3 | I0 0 1 PWL(0 0 70p 20UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | iR1 1 0 NOISE(81.114179p 0.0 1.0p) 7 | r2 1 2 1.7K 8 | L2 2 3 1uH 9 | c2 3 0 2pF 10 | r3 3 4 10K 11 | L3 4 5 5uH 12 | c3 5 0 0.2pF 13 | .PRINT DEVI I0 14 | .PRINT DEVV c3 15 | .MODEL jm JJ(RTYPE=0, ICRIT= 25UA, CAP=51.84PF) 16 | .TRAN 20n 20.01n 20n 17 | *REF 1.1e-05 FROM Likharev pg 121 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test11n.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at 0.6*IC TEMP=119 , avg voltage, beta=4, gam = 0.2 3 | I0 0 1 PWL(0 0 70p 15UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | iR1 1 0 NOISE(81.114179p 0.0 1.0p) 7 | r2 1 2 1.7K 8 | L2 2 3 1uH 9 | c2 3 0 2pF 10 | r3 3 4 10K 11 | L3 4 5 5uH 12 | c3 5 0 0.2pF 13 | .PRINT DEVI I0 14 | .PRINT DEVV c3 15 | .MODEL jm JJ(RTYPE=0, ICRIT= 25UA, CAP=51.84PF) 16 | .TRAN 20n 20.01n 20n 17 | *REF 1.4e-06 FROM Likharev pg 121 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test2.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY Inductor Pulse 3 | V0 1 0 PULSE(0 1MV 20p 5p 5p 5P 200P) 4 | L2 11 0 1.0ph 5 | R1 1 11 1p 6 | .PRINT DEVV V0 7 | .PRINT DEVI L2 8 | 9 | .TRAN 100p 100p 50p 10 | *REF 5.000e-11 0.000e-04 1.000e-02 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test3.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ below IC TEMP=0 3 | I0 0 1 PWL(0 0 30p 80UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | .PRINT DEVI I0 7 | .PRINT DEVV B2 8 | .MODEL jm JJ(RTYPE=0, ICRIT= 100UA, CAP=0.1PF) 9 | .TRAN 100p 101p 100p 10 | *REF 1.000e-10 8.000e-05 0.000e-02 11 | 12 | 13 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test4.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ above IC TEMP=0, avg voltage 3 | I0 0 1 PWL(0 0 40p 120UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | r2 1 2 1.7K 7 | L2 2 3 0.1uH 8 | c2 3 0 0.1pF 9 | r3 3 4 10K 10 | L3 4 5 0.5uH 11 | c3 5 0 0.01pF 12 | .PRINT DEVI I0 13 | .PRINT DEVV c3 14 | .MODEL jm JJ(RTYPE=0, ICRIT= 100UA, CAP=0.1PF) 15 | .TRAN 1n 2.01n 2n 16 | *REF 2.0e-9 1.20e-04 6.63e-05 17 | 18 | 19 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test5.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ above IC TEMP=0, avg voltage 3 | I0 0 1 PWL(0 0 40p 150UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | r2 1 2 1.7K 7 | L2 2 3 0.1uH 8 | c2 3 0 0.1pF 9 | r3 3 4 10K 10 | L3 4 5 0.5uH 11 | c3 5 0 0.01pF 12 | .PRINT DEVI I0 13 | .PRINT DEVV c3 14 | .MODEL jm JJ(RTYPE=0, ICRIT= 100UA, CAP=0.1PF) 15 | .TRAN 1n 2.01n 2n 16 | *REF 2.0e-9 1.50e-04 1.118e-04 17 | 18 | 19 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test6.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at IC TEMP=0, avg voltage, beta=1 3 | I0 0 1 PWL(0 0 40p 105UA 70p 100UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | r2 1 2 1.7K 7 | L2 2 3 0.1uH 8 | c2 3 0 0.1pF 9 | r3 3 4 10K 10 | L3 4 5 0.5uH 11 | c3 5 0 0.01pF 12 | .PRINT DEVI I0 13 | .PRINT DEVV c3 14 | .MODEL jm JJ(RTYPE=0, ICRIT= 100UA, CAP=3.24PF) 15 | .TRAN 2n 2.01n 2n 16 | *REF 2.0e-9 1.00e-04 4e-05 FROM Likharev pg 97 17 | *REF 2.0e-9 1.00e-04 5.5e-05 FROM my program IVX 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test7n.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at IC TEMP=119 , avg voltage, beta=0.01, gam = 0.05 3 | I0 0 1 PWL(0 0 70p 100UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | iR1 1 0 NOISE(81.114179p 0.0 1.0p) 7 | r2 1 2 1.7K 8 | L2 2 3 0.1uH 9 | c2 3 0 0.2pF 10 | r3 3 4 10K 11 | L3 4 5 0.5uH 12 | c3 5 0 0.02pF 13 | .PRINT DEVI I0 14 | .PRINT DEVV c3 15 | .MODEL jm JJ(RTYPE=0, ICRIT= 100UA, CAP=0.0324PF) 16 | .TRAN 1n 2.01n 2n 17 | *REF 2.93e-05 FROM Likharev pg 116, implemented in ah.c 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test8n.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at IC TEMP=119 , avg voltage, beta=0.04, gam = 0.2 3 | I0 0 1 PWL(0 0 70p 25UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | iR1 1 0 NOISE(81.114179p 0.0 1.0p) 7 | r2 1 2 1.7K 8 | L2 2 3 0.1uH 9 | c2 3 0 0.2pF 10 | r3 3 4 10K 11 | L3 4 5 0.5uH 12 | c3 5 0 0.02pF 13 | .PRINT DEVI I0 14 | .PRINT DEVV c3 15 | .MODEL jm JJ(RTYPE=0, ICRIT= 25UA, CAP=0.0324PF) 16 | .TRAN 2n 2.01n 2n 17 | *REF 1.16e-05 FROM Likharev pg 116 as implemented in ah.c 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/test9n.js: -------------------------------------------------------------------------------- 1 | * Generated by screen2jsim 2 | *WHY JJ at 0.6*IC TEMP=119 , avg voltage, beta=0.04, gam = 0.2 3 | I0 0 1 PWL(0 0 70p 15UA) 4 | B2 1 0 jm 5 | R1 1 0 1 6 | iR1 1 0 NOISE(81.114179p 0.0 1.0p) 7 | r2 1 2 1.7K 8 | L2 2 3 0.1uH 9 | c2 3 0 0.2pF 10 | r3 3 4 10K 11 | L3 4 5 0.5uH 12 | c3 5 0 0.02pF 13 | .PRINT DEVI I0 14 | .PRINT DEVV c3 15 | .MODEL jm JJ(RTYPE=0, ICRIT= 25UA, CAP=0.0324PF) 16 | .TRAN 2n 2.01n 2n 17 | *REF 1.48e-06 FROM Likharev pg 119 18 | 19 | 20 | -------------------------------------------------------------------------------- /vendor/jsim/jsim_n-tests/testlog: -------------------------------------------------------------------------------- 1 | test0.js 2 | *WHY OHMS LAW 3 | 5.000000000000000e-11 9.999999999999999e-05 9.999999999999999e-05 4 | *REF 5.000E-11 1.000E-04 1.000E-04 5 | 6 | test1.js 7 | *WHY Capacitor charging 8 | 5.000000000000000e-11 0.000000000000000e+00 9.999997750000272e-03 9 | *REF 5.000E-11 0.000E-04 1.000E-02 10 | 11 | test10n.js 12 | *WHY JJ at 0.8*IC TEMP=119 , avg voltage, beta=4, gam = 0.2 13 | 1.268471668612950e-05 14 | 1.020287084160951e-05 15 | 1.305369187166875e-05 16 | 1.306646230704871e-05 17 | 8.867082388432604e-06 18 | 1.079001286061733e-05 19 | 1.159116988509546e-05 20 | 8.473288766888495e-06 21 | 1.027872570653030e-05 22 | 1.323844422639207e-05 23 | 1.189167919707745e-05 24 | 1.387959002920061e-05 25 | 1.141653300727522e-05 26 | 1.029990629463449e-05 27 | 1.099284310451488e-05 28 | 1.329518579207768e-05 29 | *REF 1.1E-05 FROM LIKHAREV PG 121 30 | 31 | test11n.js 32 | *WHY JJ at 0.6*IC TEMP=119 , avg voltage, beta=4, gam = 0.2 33 | 1.869728249241387e-06 34 | 9.892188565101819e-07 35 | 9.644114900092496e-07 36 | 1.052380016916018e-06 37 | 8.696604492041685e-07 38 | 7.098114725623766e-07 39 | 1.627290623451602e-06 40 | 2.568559430474749e-06 41 | 2.451890690480505e-06 42 | 8.694186589797359e-07 43 | 8.517964780066308e-07 44 | 1.554501825979409e-06 45 | 2.088562958102584e-06 46 | 5.824937788841192e-07 47 | 9.733898092830524e-07 48 | 1.710460676655014e-06 49 | *REF 1.4E-06 FROM LIKHAREV PG 121 50 | 51 | test2.js 52 | *WHY Inductor Pulse 53 | 5.000000000000000e-11 0.000000000000000e+00 9.999999999774949e-03 54 | *REF 5.000E-11 0.000E-04 1.000E-02 55 | 56 | test3.js 57 | *WHY JJ below IC TEMP=0 58 | 1.000000000000000e-10 7.999999999999999e-05 3.658353721965467e-09 59 | *REF 1.000E-10 8.000E-05 0.000E-02 60 | 61 | test4.js 62 | *WHY JJ above IC TEMP=0, avg voltage 63 | 2.000000000000000e-09 1.200000000000000e-04 6.643533999249361e-05 64 | *REF 2.0E-9 1.20E-04 6.63E-05 65 | 66 | test5.js 67 | *WHY JJ above IC TEMP=0, avg voltage 68 | 2.000000000000000e-09 1.500000000000000e-04 1.119724639002458e-04 69 | *REF 2.0E-9 1.50E-04 1.118E-04 70 | 71 | test6.js 72 | *WHY JJ at IC TEMP=0, avg voltage, beta=1 73 | 2.000000000000000e-09 9.999999999999999e-05 5.159984093650106e-05 74 | *REF 2.0E-9 1.00E-04 4E-05 FROM LIKHAREV PG 97 75 | *REF 2.0E-9 1.00E-04 5.5E-05 FROM MY PROGRAM IVX 76 | 77 | test7n.js 78 | *WHY JJ at IC TEMP=119 , avg voltage, beta=0.01, gam = 0.05 79 | 2.712854390372946e-05 80 | 2.547087514811733e-05 81 | 3.261461638936323e-05 82 | 2.256039725269205e-05 83 | 2.961861234568485e-05 84 | 3.072583786639333e-05 85 | 2.795742592982351e-05 86 | 3.272294505044930e-05 87 | 2.563585932866958e-05 88 | 3.548853311274221e-05 89 | 3.713635240368989e-05 90 | 2.920574310540825e-05 91 | 2.873860837537627e-05 92 | 2.405353202794833e-05 93 | 2.886765671520620e-05 94 | 4.097808117954594e-05 95 | *REF 2.93E-05 FROM LIKHAREV PG 116, IMPLEMENTED IN AH.C 96 | 97 | test8n.js 98 | *WHY JJ at IC TEMP=119 , avg voltage, beta=0.04, gam = 0.2 99 | 1.005751305755844e-05 100 | 6.199789185648037e-06 101 | 1.481059047237969e-05 102 | 8.683933468019619e-06 103 | 1.503397854279831e-05 104 | 7.578171873212211e-06 105 | 9.447804387229676e-06 106 | 9.359242076852578e-06 107 | 1.213538135025012e-05 108 | 1.206735334977286e-05 109 | 1.467218352828412e-05 110 | 1.051426191422911e-05 111 | 1.291690617678502e-05 112 | 1.288280701582179e-05 113 | 1.258926911317245e-05 114 | 4.099978888912278e-06 115 | *REF 1.16E-05 FROM LIKHAREV PG 116 AS IMPLEMENTED IN AH.C 116 | 117 | test9n.js 118 | *WHY JJ at 0.6*IC TEMP=119 , avg voltage, beta=0.04, gam = 0.2 119 | 4.717319701638723e-06 120 | 2.853227730045775e-06 121 | 3.276034813384357e-06 122 | 5.797960139220887e-08 123 | 9.758746376942340e-07 124 | -3.707849075643931e-08 125 | -5.070607310016769e-09 126 | 2.308085024469765e-07 127 | 3.315410591395647e-06 128 | 2.680847592672441e-07 129 | 1.039289488790172e-06 130 | -3.656608071082204e-08 131 | 1.566207452704624e-06 132 | 1.003484307741857e-07 133 | 7.206013924798976e-07 134 | 4.324697639193120e-07 135 | *REF 1.48E-06 FROM LIKHAREV PG 119 136 | 137 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(jsimtxt C) 4 | 5 | set (JSTCOMMONSRC 6 | debug.c 7 | function.c 8 | matrix.c 9 | misc.c 10 | model.c 11 | morspace.c 12 | print.c 13 | setup.c 14 | subckt.c 15 | srchsort.c 16 | topology.c 17 | tran.c 18 | ../include/setup.h 19 | ../include/jsim.h 20 | ../include/extern.h 21 | ) 22 | 23 | add_library(jsimtxt 24 | ${JSTCOMMONSRC} 25 | ) 26 | 27 | target_include_directories(jsimtxt 28 | PUBLIC 29 | ../include 30 | ) 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDE = ../include 2 | CFLAGS = -O -g -I${INCLUDE} 3 | CC = cc 4 | TARGET = ../jsimtxt 5 | 6 | COBJS = \ 7 | debug.o \ 8 | function.o \ 9 | matrix.o \ 10 | misc.o \ 11 | model.o \ 12 | morspace.o \ 13 | picture.o \ 14 | print.o \ 15 | setup.o \ 16 | srchsort.o \ 17 | subckt.o \ 18 | topology.o \ 19 | tran.o 20 | 21 | .c.o: $*.c ${INCLUDE}/jsim.h ${INCLUDE}/extern.h 22 | $(CC) ${CFLAGS} -c $*.c 23 | 24 | 25 | library: ${TARGET}.a 26 | ${TARGET}.a: ${COBJS} 27 | ar r ${TARGET}.a $? 28 | 29 | ranlib: ${TARGET}.a 30 | ranlib ${TARGET}.a 31 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/debug.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | #include 22 | 23 | void 24 | sperror(int code) 25 | { 26 | switch (code) 27 | { 28 | case NO_MEM : printf("no memory\n"); 29 | break; 30 | 31 | case M_SINGULAR : printf("matrix singular\n"); 32 | break; 33 | 34 | case LU_FAILED : printf("LU factorization failed\n"); 35 | break; 36 | 37 | case TYPE_MATCH : 38 | printf("jj phi node cannot have other connection\n"); 39 | break; 40 | 41 | case IND_NOTDEF : printf("inductor not defined\n"); 42 | break; 43 | 44 | case EXCESS_MODEL : printf("too many jj models\n"); 45 | break; 46 | 47 | case PHANTOM_NODE : 48 | printf("print node or current does not exist in circuit\n"); 49 | break; 50 | 51 | case MOD_EXIST : printf("modal already exist\n"); 52 | break; 53 | 54 | case SMALL_TIME_STEP : 55 | printf("transient internal time step too small\n"); 56 | break; 57 | } 58 | exit(0); 59 | } /* sperror */ 60 | 61 | 62 | void 63 | print_A(matrix A) 64 | { 65 | m_data *temp; 66 | int i, element_count; 67 | 68 | element_count = 0; 69 | 70 | for (i = 0; i <= A.dim; i++) 71 | { 72 | temp = A.rowptr[i]; 73 | printf("%d row count %d, col count %d\n", i, 74 | A.r_count[i], A.c_count[i]); 75 | 76 | if (A.diagptr[i] != NULL) printf("%d %f\n", i, A.diagptr[i]->val); 77 | else printf("%d NULL\n", i); 78 | 79 | while (temp != NULL) 80 | { 81 | if (temp->type != NOTUSED) 82 | { 83 | element_count++; 84 | printf("(%d, %d) %e\n", temp->row, temp->col, temp->val); 85 | } 86 | temp = temp->n_col; 87 | } 88 | } 89 | 90 | if (A.lu_stop >= 0) 91 | printf("%f percent filled\n", 92 | 100.0*element_count/((A.lu_stop + 1)*(A.lu_stop+1))); 93 | } /* print_A */ 94 | 95 | 96 | void 97 | print_cA(matrix A) 98 | { 99 | m_data *temp; 100 | int i; 101 | 102 | for (i = 0; i <= A.dim; i++) 103 | { 104 | temp = A.colptr[i]; 105 | printf("%d row count %d, col count %d\n", i, 106 | A.r_count[i], A.c_count[i]); 107 | 108 | if (A.diagptr[i] != NULL) printf("%d %f\n", i, A.diagptr[i]->val); 109 | else printf("%d NULL\n", i); 110 | 111 | while (temp != NULL) 112 | { 113 | if (temp->type != NOTUSED) 114 | printf("(%d, %d) %e\n", temp->row, temp->col, temp->val); 115 | temp = temp->n_row; 116 | } 117 | } 118 | } /* print_cA */ 119 | 120 | 121 | void 122 | print_A_LU(matrix A) 123 | { 124 | m_data *temp; 125 | int i, element_count; 126 | 127 | element_count = 0; 128 | 129 | for (i = 0; i <= A.dim; i++) 130 | { 131 | if (A.diagptr[i] != NULL) 132 | printf("%d %f\n", i, A.diagptr[i]->lu_val); 133 | else printf("%d NULL\n", i); 134 | temp = A.rowptr[i]; 135 | while (temp != NULL) 136 | { 137 | if (temp->type != NOTUSED) 138 | { 139 | element_count++; 140 | printf("(%d, %d) %e\n", temp->row, temp->col, temp->lu_val); 141 | } 142 | temp = temp->n_col; 143 | } 144 | } 145 | printf("%f LU percent filled\n", 146 | 100.0*element_count/((A.lu_stop + 1)*(A.lu_stop + 1))); 147 | } /* print_A_LU */ 148 | 149 | 150 | void 151 | print_stat_LU(matrix A) 152 | { 153 | m_data *temp; 154 | int i, element_count, fillin_count; 155 | 156 | element_count = 0; 157 | fillin_count = 0; 158 | 159 | for (i = 0; i <= A.lu_stop; i++) 160 | { 161 | temp = A.rowptr[i]; 162 | while (temp != NULL) 163 | { 164 | if (temp->type != NOTUSED) 165 | { 166 | element_count++; 167 | } 168 | 169 | if (temp->type == FILLIN) fillin_count++; 170 | temp = temp->n_col; 171 | } 172 | } 173 | printf("%-19s%6d %-19s%6.3f\n","LU size",A.lu_stop+1, 174 | "LU percent filled", 175 | 100.0*element_count/((A.lu_stop + 1)*(A.lu_stop + 1))); 176 | 177 | printf("%-19s%6d %-19s%6d\n","Non-zero elements",element_count, 178 | "Fill-ins",fillin_count); 179 | 180 | } /* print_stat_LU */ 181 | 182 | 183 | void 184 | print_x(unknown *x, int stop, int stop2) 185 | { 186 | int i; 187 | 188 | for (i = 0; i <= stop; i++) 189 | if (x[i] != NULL) printf("(%d) %e %e\n", i, x[i]->xn, x[i]->yn); 190 | 191 | for (i = stop2; i <= eqn_count + phi_count; i++) 192 | if (x[i] != NULL) printf("(%d) %e %e\n", i, x[i]->xn, x[i]->yn); 193 | 194 | } /* print_x */ 195 | 196 | 197 | void 198 | print_b(source *b, int stop) 199 | { 200 | int i; 201 | 202 | for (i = 0; i <= stop; i++) 203 | if (b[i] != NULL) printf("(%d) %e\n", i, b[i]->val); 204 | 205 | } /* print_b */ 206 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/misc.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | #include "setup.h" 21 | #include 22 | #include 23 | 24 | char * 25 | mycalloc(int num, int size) 26 | { 27 | char *temp; 28 | 29 | temp = calloc(num, size); 30 | if (temp == NULL) sperror(NO_MEM); 31 | return(temp); 32 | 33 | } /* mycalloc */ 34 | 35 | 36 | void string_to_upper(char *line) { 37 | int a; 38 | for (a=0; line[a]!=0; a++) { 39 | int c=line[a]; 40 | if ((c>='a') && (c<='z')) { 41 | line[a] = c - 'a' + 'A'; 42 | } 43 | } 44 | } 45 | int 46 | readline(char *line) 47 | { 48 | char c; 49 | int i; 50 | int line_end; 51 | 52 | i = 0; 53 | line_end = FALSE; 54 | 55 | read_error = OK; 56 | 57 | fp=included_files[current_input_file].fp; 58 | included_files[current_input_file].line_number++; 59 | 60 | do 61 | { 62 | c = getc(fp); 63 | if ((c != '\r') && (c != '\n') && (c != EOF)) 64 | { 65 | *(line + i) = c; 66 | /* tools like auto3 depend on the output being printed upper case: */ 67 | if ((c>='a') && (c<='z')) { c=c-'a'+'A'; } 68 | 69 | printf("%c", c); 70 | i++; 71 | } 72 | else if (c == '\r') 73 | { 74 | /* Do nothing. */ 75 | } 76 | else if (c == '\n') 77 | { 78 | printf("%c", c); 79 | c = getc(fp); 80 | if (c != '+') 81 | { 82 | ungetc(c, fp); 83 | c = '\n'; 84 | line_end = TRUE; 85 | } 86 | else 87 | { 88 | printf("%c", c); 89 | *(line + i) = ' '; 90 | i++; 91 | included_files[current_input_file].line_number++; 92 | } 93 | } 94 | else line_end = TRUE; 95 | } 96 | while (line_end == FALSE); 97 | 98 | if (c == '\n') 99 | { 100 | *(line + i) = '\0'; 101 | if (!strcasecmp(line,".END")) 102 | return (EOF); 103 | return(EOF + 1); 104 | } 105 | 106 | /* end of file... */ 107 | if (current_input_file>0) { 108 | /* If this file was included, we should continue */ 109 | /* with the previous file... */ 110 | current_input_file--; 111 | *(line + i) = '\0'; 112 | return(EOF + 1); 113 | } 114 | 115 | return(EOF); 116 | 117 | } /* readline */ 118 | 119 | 120 | void 121 | ignore_separator(char *line) 122 | { 123 | while(*line != '\0') 124 | { 125 | if ((*line == ',') || (*line == '=') || (*line == '(') 126 | || (*line == ')')) *line = ' '; 127 | line++; 128 | } 129 | 130 | } /* ignore_separator */ 131 | 132 | 133 | int 134 | read_int(int *val, char *error_message, int no_mess_if_blank) 135 | { 136 | int i; 137 | 138 | while (*line == ' ' || *line == '\t') line++; 139 | 140 | tempstring[0] = '\0'; 141 | sscanf(line, "%s", tempstring); 142 | 143 | if (sscanf(tempstring, "%d", val) != 1) 144 | { 145 | if ((strlen(tempstring) > 0) || (no_mess_if_blank == FALSE)) 146 | { 147 | for (i = 0; i < line - linesave; i++) printf("#"); 148 | if (strlen(tempstring) == 0) 149 | printf("%s expected, none found\n", error_message); 150 | else printf("illegal %s value %s\n", error_message, tempstring); 151 | } 152 | 153 | line = line + strlen(tempstring); 154 | return(OK - 1); 155 | } 156 | line = line + strlen(tempstring); 157 | 158 | return(read_error); 159 | 160 | } /* read_int */ 161 | 162 | 163 | int 164 | read_long(long *val, char *error_message, int no_mess_if_blank) 165 | { 166 | int i; 167 | 168 | while (*line == ' ' || *line == '\t') line++; 169 | 170 | tempstring[0] = '\0'; 171 | sscanf(line, "%s", tempstring); 172 | 173 | if (sscanf(tempstring, "%ld", val) != 1) 174 | { 175 | if ((strlen(tempstring) > 0) || (no_mess_if_blank == FALSE)) 176 | { 177 | for (i = 0; i < line - linesave; i++) printf("#"); 178 | if (strlen(tempstring) == 0) 179 | printf("%s expected, none found\n", error_message); 180 | else printf("illegal %s value %s\n", error_message, tempstring); 181 | } 182 | 183 | line = line + strlen(tempstring); 184 | return(OK - 1); 185 | } 186 | line = line + strlen(tempstring); 187 | 188 | return(read_error); 189 | 190 | } /* read_long */ 191 | 192 | 193 | int 194 | read_string(char *error_message) 195 | { 196 | int i; 197 | 198 | tempstring[0] = '\0'; 199 | 200 | while (*line == ' ' || *line == '\t') line++; 201 | if (*line == '\0') 202 | { 203 | if (strlen(error_message) > 0) 204 | { 205 | for (i = 0; i < linesave - line; i++) printf("#"); 206 | printf("%s expected, none found\n", error_message); 207 | } 208 | 209 | return(OK - 1); 210 | } 211 | 212 | sscanf(line, "%s", tempstring); 213 | line = line + strlen(tempstring); 214 | 215 | return(read_error); 216 | 217 | } /* read_string */ 218 | 219 | 220 | char * 221 | new_string(char *tempstring) 222 | { 223 | char *str; 224 | 225 | str = mycalloc(strlen(tempstring)+1, sizeof(char)); 226 | strcpy(str, tempstring); 227 | return(str); 228 | 229 | } /* new_string */ 230 | 231 | 232 | char * 233 | combine_string(char *str1, char *str2) 234 | { 235 | int length; 236 | char *str; 237 | 238 | length = strlen(str1) + strlen(str2) + 1 ; 239 | str = mycalloc(length, sizeof(char)); 240 | strcpy(str, str1); 241 | strcat(str, str2); 242 | return(str); 243 | 244 | } /* combine_string */ 245 | 246 | 247 | char * 248 | comb_str_seg(char *str1, int count1, char *str2) 249 | { 250 | int i, length; 251 | char *str; 252 | 253 | length = count1 + 1 + strlen(str2) + 1; 254 | str = mycalloc(length, sizeof(char)); 255 | for (i = 0; i <= count1; i++) str[i] = str1[i]; 256 | str[count1+1] = '\0'; 257 | strcat(str, str2); 258 | return(str); 259 | 260 | } /* comb_str_seg */ 261 | 262 | 263 | int 264 | get_multiplier(char *str, double *val) 265 | { 266 | *val = 1.0; 267 | 268 | switch(*str) 269 | { 270 | case 'T' : *val = 1.0e12; return(OK); 271 | 272 | case 'G' : *val = 1.0e9; return(OK); 273 | 274 | case 'K' : *val = 1.0e3; return(OK); 275 | 276 | case 'U' : *val = 1.0e-6; return(OK); 277 | 278 | case 'N' : *val = 1.0e-9; return(OK); 279 | 280 | case 'P' : *val = 1.0e-12; return(OK); 281 | 282 | case 'F' : *val = 1.0e-15; return(OK); 283 | 284 | case 'M' : if (*(str + 1) == 'E') 285 | if (*(str + 2) == 'G') 286 | { 287 | *val = 1.0e6; return(OK); 288 | }; 289 | 290 | if (*(str + 1) == 'I') 291 | if (*(str + 2) == 'L') 292 | { 293 | *val = 25.4e-6; return(OK); 294 | }; 295 | 296 | *val = 1.0e-3; return(OK); 297 | 298 | default : return(OK - 1); 299 | 300 | 301 | } /* switch */ 302 | 303 | } /* get_multiplier */ 304 | 305 | 306 | int 307 | num_multiplier(char *str, double *val) 308 | { 309 | while (*str != '\0') 310 | if ((*str >= '0') && (*str <= '9')) str++; 311 | else if ((*str == '+') || (*str == '-') || (*str == '.') 312 | || (*str == 'E')) str++; 313 | else break; 314 | 315 | if (*str == '\0') return(OK - 2); 316 | return(get_multiplier(str, val)); 317 | 318 | } /* num_multiplier */ 319 | 320 | 321 | int 322 | read_double(double *val, char *error_message, int no_mess_if_blank) 323 | { 324 | int i; 325 | double multiplier; 326 | 327 | while (*line == ' ' || *line == '\t') line++; 328 | 329 | tempstring[0] = '\0'; 330 | sscanf(line, "%s", tempstring); 331 | 332 | if (sscanf(tempstring, "%lf", val) != 1) 333 | { 334 | if ((strlen(tempstring) > 0) || (no_mess_if_blank == FALSE)) 335 | { 336 | for (i = 0; i < line - linesave; i++) printf("#"); 337 | if (strlen(tempstring) < 1) 338 | printf("%s expected, none found\n", error_message); 339 | else printf("illegal %s value %s\n", error_message, tempstring); 340 | } 341 | 342 | line = line + strlen(tempstring); 343 | return(OK - 1); 344 | } 345 | line = line + strlen(tempstring); 346 | if (num_multiplier(tempstring, &multiplier) == OK) 347 | *val = *val * multiplier; 348 | 349 | return(read_error); 350 | 351 | } /* read_double */ 352 | 353 | 354 | double 355 | myabs(double x) 356 | { 357 | if (x < 0.0) return(0.0 - x); 358 | else return(x); 359 | } /* myabs */ 360 | 361 | 362 | double 363 | mymax(double x, double y) 364 | { 365 | 366 | if (x >= y) return (x); 367 | else return(y); 368 | 369 | } /* mymax */ 370 | 371 | 372 | double 373 | mymin(double x, double y) 374 | { 375 | if (x <= y) return(x); 376 | else return(y); 377 | 378 | } /* mymin */ 379 | 380 | 381 | int 382 | get_string_type(char *str) 383 | { 384 | int length; 385 | int type; 386 | 387 | length = strlen(str); 388 | 389 | switch (*str) 390 | { 391 | case 'R' : type = RESIS; break; 392 | case 'C' : type = CAP; break; 393 | case 'L' : type = INDUCT; break; 394 | case 'K' : type = MUTUAL_L; break; 395 | case 'B' : type = JJ; break; 396 | case 'X' : type = SUB_C; break; 397 | case 'V' : type = V_SOURCE; break; 398 | case 'I' : type = I_SOURCE; break; 399 | case 'T' : type = TRANSLINE; break; 400 | case '.' : type = CONTROL; break; 401 | case '*' : type = COMMENT; break; 402 | default : type = ILLEGAL; break; 403 | } 404 | 405 | if ((length < 2) && (type != COMMENT)) type = ILLEGAL; 406 | 407 | return(type); 408 | 409 | } /* get_string_type */ 410 | 411 | 412 | int 413 | get_devname_type(char *str) 414 | { 415 | char c; 416 | int i, length; 417 | 418 | length = strlen(str); 419 | 420 | if (*str == 'X') 421 | { 422 | i = length - 1; 423 | while (i >= 0) 424 | { 425 | if (*(str + i) == '_') break; 426 | i--; 427 | } 428 | if (i < 0) return(ILLEGAL); 429 | if (i >= length - 2) return(ILLEGAL); 430 | c = *(str + i + 1); 431 | } 432 | else c = *str; 433 | 434 | switch (c) 435 | { 436 | case 'R' : return(RESIS); 437 | case 'C' : return(CAP); 438 | case 'L' : return(INDUCT); 439 | case 'K' : return(MUTUAL_L); 440 | case 'B' : return(JJ); 441 | case 'V' : return(V_SOURCE); 442 | case 'I' : return(I_SOURCE); 443 | case 'T' : return(TRANSLINE); 444 | default : return(ILLEGAL); 445 | } 446 | 447 | } /* get_devname_type */ 448 | 449 | 450 | int 451 | get_string_keyword(char *keyword) 452 | { 453 | 454 | if (strcmp(keyword, ".PRINT") == 0) return(PRINT); 455 | if (strcmp(keyword, ".MODEL") == 0) return(MODEL); 456 | if (strcmp(keyword, "AREA") == 0) return(AREA); 457 | if (strcmp(keyword, "IC") == 0) return(IC); 458 | if (strcmp(keyword, "FCHECK") == 0) return(FCHECK); 459 | if (strcmp(keyword, "FVALUE") == 0) return(FVALUE); 460 | if (strcmp(keyword, ".OPTIONS") == 0) return(OPTIONS); 461 | if (strcmp(keyword, ".TRAN") == 0) return(TRAN); 462 | if (strcmp(keyword, ".FILE") == 0) return(NEWFILE); 463 | if (strcmp(keyword, ".INCLUDE") == 0) return(INCLUDEFILE); 464 | if (strcmp(keyword, ".SUBCKT") == 0) return(SUBCKT); 465 | if (strcmp(keyword, ".ENDS") == 0) return(ENDS); 466 | if (strcmp(keyword, "PWL") == 0) return(PWL); 467 | if (strcmp(keyword, "PULSE") == 0) return(PULSE); 468 | if (strcmp(keyword, "SIN") == 0) return(SIN); 469 | if (strcmp(keyword, "NOISE") == 0) return(NOISE); 470 | if (strcmp(keyword, "JJ") == 0) return(JJMODEL); 471 | if (strcmp(keyword, "XMISSION") == 0) return(TRANMODEL); 472 | if (strcmp(keyword, "NODEV") == 0) return(NODEV); 473 | if (strcmp(keyword, "DEVI") == 0) return(DEVI); 474 | if (strcmp(keyword, "DEVV") == 0) return(DEVV); 475 | if (strcmp(keyword, "PHASE") == 0) return(PHASE); 476 | if (strcmp(keyword, "CAP") == 0) return(CAPMOD); 477 | if (strcmp(keyword, "ICRIT") == 0) return(ICRIT); 478 | if (strcmp(keyword, "R0") == 0) return(R0); 479 | if (strcmp(keyword, "RN") == 0) return(RN); 480 | if (strcmp(keyword, "RTYPE") == 0) return(RTYPE); 481 | if (strcmp(keyword, "CCT") == 0) return(CCT); 482 | if (strcmp(keyword, "ICON") == 0) return(ICON); 483 | if (strcmp(keyword, "DELV") == 0) return(DELV); 484 | if (strcmp(keyword, "VG") == 0) return(VG); 485 | if (strcmp(keyword, "VNTOL") == 0) return(VNTOL); 486 | if (strcmp(keyword, "INTOL") == 0) return(INTOL); 487 | if (strcmp(keyword, "PHITOL") == 0) return(PHITOL); 488 | if (strcmp(keyword, "VRELTOL") == 0) return(VRELTOL); 489 | if (strcmp(keyword, "IRELTOL") == 0) return(IRELTOL); 490 | if (strcmp(keyword, "PHIRELTOL") == 0) return(PHIRELTOL); 491 | if (strcmp(keyword, "RELTOL") == 0) return(RELTOL); 492 | if (strcmp(keyword, "PHIQUIT") == 0) return(PHIQUIT); 493 | if (strcmp(keyword, "NUMDGT") == 0) return(NUMDGT); 494 | if (strcmp(keyword, "LTE") == 0) return(LTE); 495 | if (strcmp(keyword, "MAXPHISTEP") == 0) return(MAXPHISTEP); 496 | if (strcmp(keyword, "MAXFLUXSTEP") == 0) return(MAXFLUXSTEP); 497 | if (strcmp(keyword, "CONDEV") == 0) return(CONDEV); 498 | if (strcmp(keyword, "NUSAMPLE") == 0) return(NUSAMPLE); 499 | if (strcmp(keyword, "NUSEGMENT") == 0) return(NUSEGMENT); 500 | if (strcmp(keyword, "JJALL") == 0) return(JJALL); 501 | if (strcmp(keyword, "JJJOSEPH") == 0) return(JJJOSEPH); 502 | if (strcmp(keyword, "JJRESIS") == 0) return(JJRESIS); 503 | if (strcmp(keyword, "JJCAP") == 0) return(JJCAP); 504 | if (strcmp(keyword, "JJTOTAL") == 0) return(JJTOTAL); 505 | if (strcmp(keyword, "IGWARN") == 0) return(IGWARN); 506 | if (strcmp(keyword, "Z0") == 0) return(Z0); 507 | if (strcmp(keyword, "TD") == 0) return(TD); 508 | if (strcmp(keyword, "LOSSLESS") == 0) return(LOSSLESS); 509 | if (strcmp(keyword, "PORT1") == 0) return(PORT1); 510 | if (strcmp(keyword, "PORT2") == 0) return(PORT2); 511 | 512 | return(ILLEGAL); 513 | 514 | } /* get_string_keyword */ 515 | 516 | 517 | int 518 | source_type(int devtype) 519 | { 520 | switch(devtype) 521 | { 522 | case V_SOURCE : 523 | case PWL_V : 524 | case SIN_V : 525 | case PULSE_V : 526 | case DC_V : 527 | case NOISE_V : return(V_SOURCE); 528 | 529 | case I_SOURCE : 530 | case SIN_I : 531 | case PULSE_I : 532 | case PWL_I : 533 | case NOISE_I : return(I_SOURCE); 534 | 535 | default : return(ILLEGAL); 536 | } 537 | } /* source_type */ 538 | 539 | 540 | int 541 | is_dc_device(int devtype) 542 | { 543 | switch (devtype) 544 | { 545 | case JJ : 546 | case LOSSLESS_LINE : 547 | case V_SOURCE : 548 | case PWL_V : 549 | case SIN_V : 550 | case PULSE_V : 551 | case DC_V : 552 | case NOISE_V: 553 | case INDUCT : 554 | case RESIS : return(TRUE); 555 | 556 | default : return(FALSE); 557 | } 558 | } /* is_dc_device */ 559 | 560 | 561 | int 562 | node_type(int nodetype) 563 | { 564 | switch(nodetype) 565 | { 566 | case PLUS_NODE : 567 | case PLUS_C_NODE : return(POSITIVE); 568 | 569 | case MINUS_NODE : 570 | case MINUS_C_NODE : return(NEGATIVE); 571 | 572 | default : return(ILLEGAL); 573 | } 574 | } /* node_type */ 575 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/model.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | #include 22 | 23 | void 24 | read_model() 25 | { 26 | int type; 27 | int bad_mod = FALSE; 28 | 29 | read_error = read_string("model name"); 30 | if (read_error == OK) dev_name = new_string(tempstring); 31 | 32 | read_error = read_string("model type"); 33 | if (read_error == OK) 34 | switch(type = get_string_keyword(tempstring)) 35 | { 36 | case JJMODEL : read_jjmodel(); 37 | break; 38 | 39 | default : printf("## Error -- illegal model type %s\n", tempstring); 40 | no_go = TRUE; 41 | bad_mod = TRUE; 42 | break; 43 | 44 | } /* switch */ 45 | else 46 | { 47 | printf("## Error -- bad model definition\n"); 48 | no_go = TRUE; 49 | bad_mod = TRUE; 50 | } 51 | 52 | if (bad_mod == FALSE) 53 | { 54 | add_to_modlist(dev_name, type, intptr, dataptr); 55 | } 56 | else free(dev_name); 57 | 58 | } /* read_model */ 59 | 60 | 61 | modeldata * 62 | add_mod(char *name, int type) 63 | { 64 | modeldata *temp_model; 65 | 66 | temp_model = (modeldata *) calloc(1, sizeof(modeldata)); 67 | mod_count++; 68 | temp_model->name = name; 69 | temp_model->type = type; 70 | temp_model->data = NULL; 71 | temp_model->next_model = NULL; 72 | 73 | if (jsim_model == NULL) 74 | { 75 | jsim_model = jsim_model_tail = temp_model; 76 | } 77 | else 78 | { 79 | jsim_model_tail->next_model = temp_model; 80 | jsim_model_tail = temp_model; 81 | } 82 | 83 | return(temp_model); 84 | 85 | } /* add_mod */ 86 | 87 | 88 | modeldata * 89 | add_to_modlist(char *name, int type, long *intptr, double *dataptr) 90 | { 91 | modeldata *add_mod(); 92 | modeldata *modptr; 93 | 94 | modptr = add_mod(name, type); 95 | 96 | if (type == JJMODEL) 97 | { 98 | assign_jj_mod(modptr, *intptr, *dataptr, *(dataptr+1), 99 | *(dataptr+2), *(dataptr+3), *(dataptr+4), 100 | *(dataptr+5), *(intptr+1), *(dataptr+6)); 101 | } 102 | return(modptr); 103 | 104 | } /* add_to_modlist */ 105 | 106 | 107 | void 108 | read_jjmodel() 109 | { 110 | 111 | *intptr = DEF_RTYPE; 112 | *(intptr + 1) = DEF_CCT; 113 | *dataptr = DEF_ICRIT; 114 | *(dataptr + 1) = DEF_JJCAP; 115 | *(dataptr + 2) = DEF_VG; 116 | *(dataptr + 3) = DEF_R0; 117 | *(dataptr + 4) = DEF_DELV; 118 | *(dataptr + 5) = DEF_RN; 119 | *(dataptr + 6) = DEF_ICON; 120 | 121 | while ((read_error = read_string("")) == OK) 122 | { 123 | switch(get_string_keyword(tempstring)) 124 | { 125 | case RTYPE : 126 | read_error = read_long(intptr, "IV type", FALSE); 127 | break; 128 | case CCT : 129 | read_error = read_long(intptr+1, "CCT type", FALSE); 130 | break; 131 | case ICRIT : 132 | read_error = read_double(dataptr, "critical current", FALSE); 133 | break; 134 | case CAPMOD : 135 | read_error = read_double(dataptr+1, "junction cap", FALSE); 136 | break; 137 | case VG : 138 | read_error = read_double(dataptr+2, "gap voltage", FALSE); 139 | break; 140 | case R0 : 141 | read_error = read_double(dataptr+3, "subgap resistance", 142 | FALSE); 143 | break; 144 | case DELV : 145 | read_error = read_double(dataptr+4, "delta voltage", FALSE); 146 | break; 147 | case RN : 148 | read_error = read_double(dataptr+5, "normal resistance", 149 | FALSE); 150 | break; 151 | case ICON : 152 | read_error = read_double(dataptr+6, "ICON val", FALSE); 153 | break; 154 | 155 | default : 156 | printf("## Warning -- illegal keyword %s\n", tempstring); 157 | warned = TRUE; 158 | break; 159 | 160 | } /* switch */ 161 | 162 | } /* while */ 163 | 164 | } /* read_jjmodel */ 165 | 166 | 167 | void 168 | assign_jj_mod(modeldata *modptr, int rtype, double ic, double cap, 169 | double vgap, double rg, double del_v, double rn, int cct, double icon) 170 | { 171 | mod_jj *temp_mod; 172 | 173 | modptr->data = mycalloc(1, sizeof(mod_jj)); 174 | temp_mod = (mod_jj *) modptr->data; 175 | temp_mod->rtype = rtype; 176 | temp_mod->ic = ic; 177 | temp_mod->cap = cap; 178 | temp_mod->vgap = vgap; 179 | temp_mod->rg = rg; 180 | temp_mod->del_v = del_v; 181 | temp_mod->rn = rn; 182 | temp_mod->glarge = ((1.0/rn)*(vgap + del_v) - (1.0/rg)*vgap) 183 | /del_v; 184 | temp_mod->cct = cct; 185 | temp_mod->icon = icon; 186 | temp_mod->quasi_bkpoint[0] = vgap - mymin(0.1*vgap, del_v); 187 | temp_mod->quasi_bkpoint[1] = vgap; 188 | temp_mod->quasi_bkpoint[2] = vgap + del_v; 189 | temp_mod->quasi_bkpoint[3] = vgap + del_v + mymin(0.1*vgap, del_v); 190 | 191 | } /* assign_jj_mod */ 192 | 193 | 194 | double 195 | jjiv(double val, modeldata *mod) 196 | { 197 | mod_jj *temp_jj; 198 | double temp_val, abs_val; 199 | 200 | abs_val = myabs(val); 201 | 202 | temp_jj = (mod_jj *) mod->data; 203 | 204 | if (temp_jj->rtype == JJ_PWL) 205 | { 206 | temp_jj = (mod_jj *) mod->data; 207 | if (abs_val <= temp_jj->vgap) return(val/temp_jj->rg); 208 | else if (abs_val <= temp_jj->vgap + temp_jj->del_v) 209 | { 210 | temp_val = temp_jj->vgap/temp_jj->rg; 211 | temp_val = temp_val + 212 | ((temp_jj->vgap + temp_jj->del_v)/temp_jj->rn 213 | - temp_jj->vgap/temp_jj->rg)* 214 | ((abs_val - temp_jj->vgap)/temp_jj->del_v); 215 | if (val >= 0.0) return(temp_val); 216 | else return(0.0 - temp_val); 217 | } 218 | else return(val/temp_jj->rn); 219 | } 220 | 221 | return(0.0); 222 | 223 | } /* jjiv */ 224 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/morspace.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | #include 22 | 23 | void 24 | free_devarray() 25 | { 26 | if (resis_array != NULL) 27 | { 28 | free((char *) resis_array); 29 | resis_array = NULL; 30 | } 31 | 32 | if (cap_array != NULL) 33 | { 34 | free((char *) cap_array); 35 | cap_array = NULL; 36 | } 37 | 38 | if (ind_array != NULL) 39 | { 40 | free((char *) ind_array); 41 | ind_array = NULL; 42 | } 43 | 44 | if (jj_array != NULL) 45 | { 46 | free((char *) jj_array); 47 | jj_array = NULL; 48 | } 49 | 50 | if (mut_array != NULL) 51 | { 52 | free((char *) mut_array); 53 | mut_array = NULL; 54 | } 55 | 56 | if (sub_ckt_array != NULL) 57 | { 58 | free((char *) sub_ckt_array); 59 | sub_ckt_array = NULL; 60 | } 61 | 62 | if (vsource_array != NULL) 63 | { 64 | free((char *) vsource_array); 65 | vsource_array = NULL; 66 | } 67 | 68 | if (isource_array != NULL) 69 | { 70 | free((char *) isource_array); 71 | isource_array = NULL; 72 | } 73 | 74 | } /* free_devarray */ 75 | 76 | 77 | void 78 | free_name() 79 | { 80 | long i; 81 | 82 | for (i = 0; i < dev_count; i++) 83 | { 84 | free((char *) realname_array[i]); 85 | realname_array[i] = (long)NULL; 86 | } 87 | 88 | if (realname_array != NULL) 89 | { 90 | free((char *) realname_array); 91 | realname_array = NULL; 92 | } 93 | 94 | if (name_array != NULL) 95 | { 96 | free((char *) name_array); 97 | name_array = NULL; 98 | } 99 | 100 | } /* free_name */ 101 | 102 | 103 | void 104 | free_def_tree() 105 | { 106 | int i; 107 | 108 | for (i=0; i < sub_def_count; i++) 109 | { 110 | free_sub_def((sub_def *) sub_def_array[i]); 111 | free((char *) sub_def_array[i]); 112 | sub_def_array[i] = (long)NULL; 113 | } 114 | 115 | if (sub_def_array != NULL) 116 | { 117 | free((char *) sub_def_array); 118 | sub_def_array = NULL; 119 | } 120 | 121 | } /* free_def_tree */ 122 | 123 | 124 | void 125 | free_sub_def(sub_def*the_sub) 126 | { 127 | int i; 128 | device *temp_dev; 129 | 130 | free((char *) the_sub->node_list); 131 | the_sub->node_list = NULL; 132 | 133 | for (i = 0; i < the_sub->sub_dev_count; i++) 134 | { 135 | temp_dev = (device *) the_sub->sub_dev_array[i]; 136 | free(temp_dev->data); 137 | temp_dev->data = NULL; 138 | free((char *) the_sub->sub_dev_array[i]); 139 | the_sub->sub_dev_array[i] = (long)NULL; 140 | } 141 | 142 | if (the_sub->sub_dev_array != NULL) 143 | { 144 | free((char *) the_sub->sub_dev_array); 145 | the_sub->sub_dev_array = NULL; 146 | } 147 | 148 | for (i = 0; i < the_sub->sub_sub_count; i++) 149 | { 150 | free_sub_def((sub_def *) the_sub->sub_sub_array[i]); 151 | free((char *) the_sub->sub_sub_array[i]); 152 | the_sub->sub_sub_array[i] = (long)NULL; 153 | } 154 | 155 | if (the_sub->sub_sub_array != NULL) 156 | { 157 | free((char *) the_sub->sub_sub_array); 158 | the_sub->sub_sub_array = NULL; 159 | } 160 | 161 | } /* free_sub_def */ 162 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/print.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | #include 22 | 23 | void 24 | read_file() 25 | { 26 | int i; 27 | FILE *temp_fp, *fopen(); 28 | 29 | if (jsim_raw) { 30 | (void) read_string(""); 31 | return; 32 | } 33 | 34 | read_error = read_string("file name to open"); 35 | 36 | if (read_error != OK) 37 | { 38 | printf("## Warning -- illegal file specification\n"); 39 | printf("## Warning -- output directed to last file specified\n"); 40 | return; 41 | } 42 | 43 | if (strcmp(tempstring, "STDOUT") == 0) 44 | { 45 | fileptr[MAXFILE] = stdout; 46 | current_fp = stdout; 47 | return; 48 | } 49 | 50 | for (i = 0; i <= file_count; i++) 51 | if (strcmp(tempstring, filename[i]) == 0) 52 | { 53 | current_fp = fileptr[i]; 54 | return; 55 | } 56 | 57 | if (file_count == MAXFILE - 1) 58 | { 59 | printf("## Warning -- cannot specify more than %d files\n", 60 | MAXFILE); 61 | printf("## Warning -- output directed to last file specified\n"); 62 | return; 63 | } 64 | 65 | temp_fp = fopen(tempstring, "w"); 66 | 67 | if (temp_fp == NULL) 68 | { 69 | printf("## Warning -- cannot open file %s\n", tempstring); 70 | printf("## Warning -- output directed to last file specified\n"); 71 | return; 72 | } 73 | 74 | file_count++; 75 | filename[file_count] = new_string(tempstring); 76 | fileptr[file_count] = temp_fp; 77 | current_fp = temp_fp; 78 | 79 | } /* read_file */ 80 | 81 | 82 | void 83 | read_print() 84 | { 85 | int first_node, second_node, whichpart; 86 | char *dev_name; 87 | 88 | 89 | if (current_fp == stdout) fileptr[MAXFILE] = stdout; 90 | 91 | read_error = read_string("print type"); 92 | 93 | if (read_error == OK) 94 | switch(get_string_keyword(tempstring)) 95 | { 96 | case NODEV : 97 | second_node = 0; 98 | read_error = read_int(&first_node, "plus node", FALSE); 99 | read_error = read_int(&second_node, "minus node", FALSE); 100 | if (read_error == OK) 101 | add_pr_node(current_fp, first_node, second_node); 102 | break; 103 | 104 | case DEVV : 105 | read_error = read_string("device name"); 106 | dev_name = new_string(tempstring); 107 | if (read_error == OK) 108 | { 109 | read_error = read_string(""); 110 | if (read_error == OK) 111 | whichpart = get_string_keyword(tempstring); 112 | else whichpart = ILLEGAL; 113 | 114 | add_pr_device(current_fp, dev_name, VOLT, whichpart); 115 | } 116 | break; 117 | 118 | case DEVI : 119 | read_error = read_string("device name"); 120 | dev_name = new_string(tempstring); 121 | if (read_error == OK) 122 | { 123 | read_error = read_string(""); 124 | if (read_error == OK) 125 | whichpart = get_string_keyword(tempstring); 126 | else whichpart = ILLEGAL; 127 | 128 | add_pr_device(current_fp, dev_name, AMP, whichpart); 129 | } 130 | break; 131 | 132 | case PHASE : 133 | read_error = read_string("device name"); 134 | dev_name = new_string(tempstring); 135 | add_pr_device(current_fp, dev_name, PHI, whichpart); 136 | break; 137 | 138 | default: 139 | printf("## Error -- illegal print type %s\n", tempstring); 140 | no_go = TRUE; 141 | break; 142 | 143 | } /* switch */ 144 | else 145 | { 146 | printf("## Error -- bad print request\n"); 147 | no_go = TRUE; 148 | } 149 | 150 | } /* read_print */ 151 | 152 | 153 | void 154 | add_pr_node(FILE *fp, int plus, int minus) 155 | { 156 | printdata *temp_print; 157 | 158 | temp_print = (printdata *) mycalloc(1, sizeof(printdata)); 159 | 160 | temp_print->fp = fp; 161 | temp_print->plus = plus; 162 | temp_print->minus = minus; 163 | temp_print->is_dev = FALSE; 164 | temp_print->next_print = NULL; 165 | 166 | if (print_list == NULL) print_list = print_tail = temp_print; 167 | else 168 | { 169 | print_tail->next_print = temp_print; 170 | print_tail = temp_print; 171 | } 172 | } /* add_pr_node */ 173 | 174 | 175 | void 176 | add_pr_device(FILE *fp, char *name, int prtype, int subtype) 177 | { 178 | printdata *temp_print; 179 | 180 | temp_print = (printdata *) mycalloc(1, sizeof(printdata)); 181 | 182 | temp_print->fp = fp; 183 | temp_print->dev_name = name; 184 | temp_print->prtype = prtype; 185 | temp_print->subtype = subtype; 186 | temp_print->is_dev = TRUE; 187 | temp_print->next_print = NULL; 188 | 189 | if (print_list == NULL) print_list = print_tail = temp_print; 190 | else 191 | { 192 | print_tail->next_print = temp_print; 193 | print_tail = temp_print; 194 | } 195 | } /* add_pr_device */ 196 | 197 | 198 | void 199 | do_print() 200 | { 201 | printdata *temp_print; 202 | node_to_eqn *temp_node_eqn; 203 | int type; 204 | device *temp_dev; 205 | 206 | temp_print = print_list; 207 | 208 | while (temp_print != NULL) 209 | { 210 | if (temp_print->is_dev == FALSE) 211 | { 212 | if (temp_print->plus == 0) temp_print->plus = ground_node; 213 | else 214 | { 215 | temp_node_eqn = search_node(temp_print->plus); 216 | if (temp_node_eqn != NULL) 217 | temp_print->plus = temp_node_eqn->n_eq; 218 | else 219 | { 220 | printf("## Error -- print node %d not defined\n", 221 | temp_print->plus); 222 | no_go = TRUE; 223 | } 224 | } 225 | 226 | if (temp_print->minus == 0) temp_print->minus = ground_node; 227 | else 228 | { 229 | temp_node_eqn = search_node(temp_print->minus); 230 | if (temp_node_eqn != NULL) 231 | temp_print->minus = temp_node_eqn->n_eq; 232 | else 233 | { 234 | printf("## Error -- print node %d not defined\n", 235 | temp_print->minus); 236 | no_go = TRUE; 237 | } 238 | } 239 | } 240 | else /* is_dev is TRUE */ 241 | { 242 | type = get_devname_type(temp_print->dev_name); 243 | if ((type != ILLEGAL) && (type != COMMENT)) 244 | { 245 | temp_dev = find_dev(temp_print->dev_name, type); 246 | if (temp_dev != NULL) 247 | temp_print->print_dev = temp_dev; 248 | else 249 | { 250 | printf("## Error -- print device %s not found\n", 251 | temp_print->dev_name); 252 | no_go = TRUE; 253 | } 254 | } 255 | else 256 | { 257 | printf("## Error -- illegal print device name %s\n", 258 | temp_print->dev_name); 259 | no_go = TRUE; 260 | } 261 | } 262 | 263 | temp_print = temp_print->next_print; 264 | 265 | } /* while */ 266 | 267 | } /* do_print */ 268 | 269 | 270 | /* Print line of all variable names as column header. */ 271 | void print_header(FILE *fp) { 272 | printdata *temp_print; 273 | int printed = 0; 274 | char* type_name; 275 | 276 | temp_print = print_list; 277 | 278 | if (temp_print != NULL) { 279 | printed = 1; 280 | fprintf(fp, "time "); 281 | } 282 | 283 | while (temp_print != NULL) { 284 | 285 | 286 | if (temp_print->is_dev) { 287 | switch(temp_print->prtype) { 288 | case VOLT: 289 | type_name = "V"; break; 290 | case AMP: 291 | type_name = "I"; break; 292 | case PHI: 293 | type_name = "P"; break; 294 | case VOLT_TIME: 295 | type_name = "VT"; break; 296 | case AMP_TIME: 297 | type_name = "IT"; break; 298 | default: 299 | type_name = "U"; break; 300 | } 301 | fprintf(fp, "%s_%s", temp_print->dev_name, type_name); 302 | } else { 303 | 304 | if (temp_print->minus == ground_node) { 305 | fprintf(fp, "NV%d", temp_print->plus); 306 | } else if (temp_print->plus == ground_node) { 307 | fprintf(fp, "NV%d_%d", 0, temp_print->minus); 308 | } else { 309 | fprintf(fp, "NV%d_%d", temp_print->plus, temp_print->minus); 310 | } 311 | 312 | } 313 | temp_print = temp_print->next_print; 314 | if (temp_print != NULL) { 315 | fprintf(fp, " "); 316 | } 317 | } 318 | 319 | if (printed) { 320 | fprintf(fp, "\n"); 321 | } 322 | 323 | } /* print_header */ 324 | 325 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/srchsort.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | #include 22 | #include 23 | 24 | long *temp_array; 25 | 26 | 27 | void 28 | merge_copy(long *the_array, long lower, long upper) 29 | { 30 | long i; 31 | 32 | for (i = lower; i <= upper; i++) 33 | *(temp_array + i - lower) = *(the_array + i); 34 | 35 | } /* merge_copy */ 36 | 37 | 38 | void 39 | sort_realname(long lower, long upper) 40 | { 41 | long mid; 42 | 43 | if (lower == upper) return; 44 | mid = (lower + upper) / 2; 45 | sort_realname(lower, mid); 46 | sort_realname(mid+1, upper); 47 | merge_realname(lower, mid, upper); 48 | return; 49 | 50 | } /* sort_realname */ 51 | 52 | 53 | void 54 | merge_realname(long lower, long mid, long upper) 55 | { 56 | long i, j, k; 57 | int temp; 58 | 59 | merge_copy(realname_array, lower, mid); 60 | i = 0; 61 | j = mid + 1; 62 | k = lower; 63 | while ((i <= mid - lower) && (j <= upper)) 64 | { 65 | temp = strcmp(((realname_name *) (*(temp_array + i)))->real_name, 66 | ((realname_name *) (*(realname_array + j)))->real_name); 67 | if (temp == 0) 68 | { 69 | *(realname_array + k) = *(temp_array + i); 70 | k++; i++; 71 | *(realname_array + k) = *(realname_array + j); 72 | k++; j++; 73 | } 74 | else if (temp < 0) 75 | { 76 | *(realname_array + k) = *(temp_array + i); 77 | k++; i++; 78 | } 79 | else 80 | { 81 | *(realname_array + k) = *(realname_array + j); 82 | k++; j++; 83 | } 84 | } /* while */ 85 | 86 | if (i <= mid - lower) 87 | while (i <= mid - lower) 88 | { 89 | *(realname_array + k) = *(temp_array + i); 90 | k++; i++; 91 | } 92 | 93 | } /* merge_realname */ 94 | 95 | 96 | void 97 | get_realname_array() 98 | { 99 | long i; 100 | realname_name *temp_name; 101 | 102 | if (dev_count <= 0) return; 103 | 104 | realname_array = (long *) mycalloc(dev_count, sizeof(long)); 105 | 106 | temp_name = namelist; 107 | i = 0; 108 | while (temp_name != NULL) 109 | { 110 | *(realname_array + i) = (long) temp_name; 111 | i++; 112 | temp_name = temp_name->next_name; 113 | } 114 | 115 | if (dev_count > 1) 116 | { 117 | temp_array = (long *) mycalloc(dev_count/2 + 1, sizeof(long)); 118 | sort_realname(0, dev_count - 1); 119 | free((char *) temp_array); 120 | } 121 | 122 | } /* get_realname_array */ 123 | 124 | 125 | void 126 | get_name_array() 127 | { 128 | long i; 129 | realname_name *temp_name; 130 | 131 | if (dev_count <= 0) return; 132 | 133 | name_array = (long *) mycalloc(dev_count, sizeof(long)); 134 | 135 | temp_name = namelist; 136 | i = 0; 137 | while (temp_name != NULL) 138 | { 139 | *(name_array + i) = (long) temp_name; 140 | i++; 141 | temp_name = temp_name->next_name; 142 | } 143 | 144 | } /* get_name_array */ 145 | 146 | 147 | realname_name * 148 | search_realname(char *real_name) 149 | { 150 | int lower, mid, upper; 151 | int temp; 152 | 153 | lower = 0; 154 | upper = dev_count - 1; 155 | 156 | while (lower <= upper) 157 | { 158 | mid = (lower + upper)/2; 159 | temp = strcmp(real_name, 160 | ((realname_name *) (*(realname_array + mid)))->real_name); 161 | if (temp == 0) 162 | return((realname_name *) (*(realname_array + mid))); 163 | else if (temp < 0) upper = mid - 1; 164 | else lower = mid + 1; 165 | } 166 | return(NULL); 167 | 168 | } /* search_realname */ 169 | 170 | 171 | realname_name * 172 | search_name(long name) 173 | { 174 | 175 | if ((name > dev_count) || (name <= 0)) return(NULL); 176 | return((realname_name *) (*(name_array + name - 1))); 177 | 178 | } /* search_name */ 179 | 180 | 181 | void 182 | sort_dev(long *dev_array, long lower, long upper) 183 | { 184 | long mid; 185 | 186 | if (lower == upper) return; 187 | mid = (lower + upper) / 2; 188 | sort_dev(dev_array, lower, mid); 189 | sort_dev(dev_array, mid+1, upper); 190 | merge_dev(dev_array, lower, mid, upper); 191 | return; 192 | 193 | } /* sort_dev */ 194 | 195 | 196 | void 197 | merge_dev(long *dev_array, long lower, long mid, long upper) 198 | { 199 | long i, j, k; 200 | int temp; 201 | 202 | merge_copy(dev_array, lower, mid); 203 | i = 0; 204 | j = mid + 1; 205 | k = lower; 206 | while ((i <= mid - lower) && (j <= upper)) 207 | { 208 | temp = strcmp((char*)((device *) (*(temp_array + i)))->name, 209 | (char*)((device *) (*(dev_array + j)))->name); 210 | if (temp == 0) 211 | { 212 | *(dev_array + k) = *(temp_array + i); 213 | k++; i++; 214 | *(dev_array + k) = *(dev_array + j); 215 | k++; j++; 216 | } 217 | else if (temp < 0) 218 | { 219 | *(dev_array + k) = *(temp_array + i); 220 | k++; i++; 221 | } 222 | else 223 | { 224 | *(dev_array + k) = *(dev_array + j); 225 | k++; j++; 226 | } 227 | } /* while */ 228 | 229 | if (i <= mid - lower) 230 | while (i <= mid - lower) 231 | { 232 | *(dev_array + k) = *(temp_array + i); 233 | k++; i++; 234 | } 235 | 236 | } /* merge_dev */ 237 | 238 | 239 | long * 240 | get_dev_array(int no_sort, device *dev_list, long dev_count) 241 | { 242 | long i, *temp_dev_array; 243 | device *temp_dev; 244 | 245 | if (dev_count <= 0) return(NULL); 246 | 247 | temp_dev_array = (long *) mycalloc(dev_count, sizeof(long)); 248 | 249 | temp_dev = dev_list; 250 | i = 0; 251 | while (temp_dev != NULL) 252 | { 253 | *(temp_dev_array + i) = (long) temp_dev; 254 | i++; 255 | temp_dev = temp_dev->next_dev; 256 | } 257 | 258 | if ((no_sort == FALSE) && (dev_count > 1)) 259 | { 260 | temp_array = (long *) mycalloc(dev_count/2 + 1, sizeof(long)); 261 | sort_dev(temp_dev_array, 0, dev_count - 1); 262 | free((char *) temp_array); 263 | } 264 | 265 | return(temp_dev_array); 266 | 267 | } /* get_dev_array */ 268 | 269 | 270 | device * 271 | search_dev(long *dev_array, long dev_count, char *name) 272 | { 273 | long lower, mid, upper; 274 | int temp; 275 | 276 | lower = 0; 277 | upper = dev_count - 1; 278 | 279 | while (lower <= upper) 280 | { 281 | mid = (lower + upper)/2; 282 | temp = strcmp(name, 283 | (char *) ((device *) (*(dev_array + mid)))->name); 284 | if (temp == 0) 285 | return((device *) (*(dev_array + mid))); 286 | else if (temp < 0) upper = mid - 1; 287 | else lower = mid + 1; 288 | } 289 | return(NULL); 290 | 291 | } /* search_dev */ 292 | 293 | 294 | device * 295 | search_name_dev(long *dev_array, long dev_count, long name) 296 | { 297 | long lower, mid, upper; 298 | long temp; 299 | 300 | lower = 0; 301 | upper = dev_count - 1; 302 | 303 | while (lower <= upper) 304 | { 305 | mid = (lower + upper)/2; 306 | temp = name - ((device *) (*(dev_array + mid)))->name; 307 | if (temp == 0) 308 | return((device *) (*(dev_array + mid))); 309 | else if (temp < 0) upper = mid - 1; 310 | else lower = mid + 1; 311 | } 312 | return(NULL); 313 | 314 | } /* search_name_dev */ 315 | 316 | 317 | void 318 | sort_sub_def(long *sub_def_array, long lower, long upper) 319 | { 320 | long mid; 321 | 322 | if (lower == upper) return; 323 | mid = (lower + upper) / 2; 324 | sort_sub_def(sub_def_array, lower, mid); 325 | sort_sub_def(sub_def_array, mid+1, upper); 326 | merge_sub_def(sub_def_array, lower, mid, upper); 327 | return; 328 | 329 | } /* sort_sub_def */ 330 | 331 | 332 | void 333 | merge_sub_def(long *sub_def_array, long lower, long mid, long upper) 334 | { 335 | long i, j, k; 336 | int temp; 337 | 338 | merge_copy(sub_def_array, lower, mid); 339 | i = 0; 340 | j = mid + 1; 341 | k = lower; 342 | while ((i <= mid - lower) && (j <= upper)) 343 | { 344 | temp = strcmp(((sub_def *) (*(temp_array + i)))->name, 345 | ((sub_def *) (*(sub_def_array + j)))->name); 346 | if (temp == 0) 347 | { 348 | *(sub_def_array + k) = *(temp_array + i); 349 | k++; i++; 350 | *(sub_def_array + k) = *(sub_def_array + j); 351 | k++; j++; 352 | } 353 | else if (temp < 0) 354 | { 355 | *(sub_def_array + k) = *(temp_array + i); 356 | k++; i++; 357 | } 358 | else 359 | { 360 | *(sub_def_array + k) = *(sub_def_array + j); 361 | k++; j++; 362 | } 363 | } /* while */ 364 | 365 | if (i <= mid - lower) 366 | while (i <= mid - lower) 367 | { 368 | *(sub_def_array + k) = *(temp_array + i); 369 | k++; i++; 370 | } 371 | 372 | } /* merge_sub_def */ 373 | 374 | 375 | long * 376 | get_sub_def_array(sub_def *sub_def_list, long sub_def_count) 377 | { 378 | long i, *temp_sub_def_array, *get_dev_array(); 379 | sub_def *temp_sub_def; 380 | 381 | if (sub_def_count <= 0) return(NULL); 382 | 383 | temp_sub_def_array = (long *) mycalloc(sub_def_count, sizeof(long)); 384 | 385 | temp_sub_def = sub_def_list; 386 | i = 0; 387 | while (temp_sub_def != NULL) 388 | { 389 | *(temp_sub_def_array + i) = (long) temp_sub_def; 390 | i++; 391 | temp_sub_def = temp_sub_def->next_sub; 392 | } 393 | 394 | if (sub_def_count > 1) 395 | { 396 | temp_array = (long *) mycalloc(sub_def_count/2 + 1, sizeof(long)); 397 | sort_sub_def(temp_sub_def_array, 0, sub_def_count - 1); 398 | free((char *) temp_array); 399 | } 400 | 401 | temp_sub_def = sub_def_list; 402 | while (temp_sub_def != NULL) 403 | { 404 | temp_sub_def->sub_dev_array = 405 | get_dev_array(FALSE, temp_sub_def->the_sub_ckt, 406 | temp_sub_def->sub_dev_count); 407 | temp_sub_def = temp_sub_def->next_sub; 408 | } 409 | 410 | temp_sub_def = sub_def_list; 411 | while (temp_sub_def != NULL) 412 | { 413 | temp_sub_def->sub_sub_array = 414 | get_sub_def_array(temp_sub_def->sub_sub, 415 | temp_sub_def->sub_sub_count); 416 | temp_sub_def = temp_sub_def->next_sub; 417 | } 418 | 419 | return(temp_sub_def_array); 420 | 421 | } /* get_sub_def_array */ 422 | 423 | 424 | sub_def * 425 | search_sub_def(long *sub_def_array, long sub_def_count, char *name) 426 | { 427 | int lower, mid, upper; 428 | int temp; 429 | 430 | lower = 0; 431 | upper = sub_def_count - 1; 432 | 433 | while (lower <= upper) 434 | { 435 | mid = (lower + upper)/2; 436 | temp = strcmp(name, 437 | (char *) ((sub_def *) (*(sub_def_array + mid)))->name); 438 | if (temp == 0) 439 | return((sub_def *) (*(sub_def_array + mid))); 440 | else if (temp < 0) upper = mid - 1; 441 | else lower = mid + 1; 442 | } 443 | return(NULL); 444 | 445 | } /* search_sub_def */ 446 | 447 | 448 | void 449 | get_eqn_array() 450 | { 451 | int i; 452 | node_to_eqn *temp_node_eqn; 453 | 454 | if (eqn_count < 0) return; 455 | 456 | eqn_array = (long *) mycalloc(eqn_count + 1, sizeof(long)); 457 | 458 | for (i = 0; i < RANGE; i++) 459 | { 460 | temp_node_eqn = node_map[i]; 461 | 462 | while (temp_node_eqn != NULL) 463 | { 464 | *(eqn_array + temp_node_eqn->n_eq) = (long) temp_node_eqn; 465 | temp_node_eqn = temp_node_eqn->next_node; 466 | } 467 | } 468 | 469 | } /* get_eqn_array */ 470 | 471 | 472 | void 473 | sort_node(long lower, long upper) 474 | { 475 | long mid; 476 | 477 | if (lower == upper) return; 478 | mid = (lower + upper) / 2; 479 | sort_node(lower, mid); 480 | sort_node(mid+1, upper); 481 | merge_node(lower, mid, upper); 482 | return; 483 | 484 | } /* sort_node */ 485 | 486 | 487 | void 488 | merge_node(long lower, long mid, long upper) 489 | { 490 | long i, j, k; 491 | int temp; 492 | 493 | merge_copy(node_array, lower, mid); 494 | i = 0; 495 | j = mid + 1; 496 | k = lower; 497 | while ((i <= mid - lower) && (j <= upper)) 498 | { 499 | temp = ((node_to_eqn *) (*(temp_array + i)))->node - 500 | ((node_to_eqn *) (*(node_array + j)))->node; 501 | if (temp == 0) 502 | { 503 | *(node_array + k) = *(temp_array + i); 504 | k++; i++; 505 | *(node_array + k) = *(node_array + j); 506 | k++; j++; 507 | } 508 | else if (temp < 0) 509 | { 510 | *(node_array + k) = *(temp_array + i); 511 | k++; i++; 512 | } 513 | else 514 | { 515 | *(node_array + k) = *(node_array + j); 516 | k++; j++; 517 | } 518 | } /* while */ 519 | 520 | if (i <= mid - lower) 521 | while (i <= mid - lower) 522 | { 523 | *(node_array + k) = *(temp_array + i); 524 | k++; i++; 525 | } 526 | 527 | } /* merge_node */ 528 | 529 | 530 | void 531 | get_node_array() 532 | { 533 | long i; 534 | int j; 535 | node_to_eqn *temp_node_eqn; 536 | 537 | if (node_count <= 0) return; 538 | 539 | node_array = (long *) mycalloc(node_count, sizeof(long)); 540 | 541 | i = 0; 542 | for (j = 0; j < RANGE; j++) 543 | { 544 | temp_node_eqn = node_map[j]; 545 | while (temp_node_eqn != NULL) 546 | { 547 | *(node_array + i) = (long) temp_node_eqn; 548 | i++; 549 | temp_node_eqn = temp_node_eqn->next_node; 550 | } 551 | } 552 | 553 | if (node_count > 1) 554 | { 555 | temp_array = (long *) mycalloc(node_count/2 + 1, sizeof(long)); 556 | sort_node(0, node_count - 1); 557 | free((char *) temp_array); 558 | } 559 | 560 | } /* get_node_array */ 561 | 562 | 563 | node_to_eqn * 564 | search_node(int node) 565 | { 566 | long lower, mid, upper; 567 | int temp; 568 | 569 | lower = 0; 570 | upper = node_count - 1; 571 | 572 | while (lower <= upper) 573 | { 574 | mid = (lower + upper)/2; 575 | temp = node - 576 | ((node_to_eqn *) (*(node_array + mid)))->node; 577 | if (temp == 0) 578 | return((node_to_eqn *) (*(node_array + mid))); 579 | else if (temp < 0) upper = mid - 1; 580 | else lower = mid + 1; 581 | } 582 | return(NULL); 583 | 584 | } /* search_node */ 585 | 586 | 587 | void 588 | sort_model(long lower, long upper) 589 | { 590 | long mid; 591 | 592 | if (lower == upper) return; 593 | mid = (lower + upper) / 2; 594 | sort_model(lower, mid); 595 | sort_model(mid+1, upper); 596 | merge_model(lower, mid, upper); 597 | return; 598 | 599 | } /* sort_model */ 600 | 601 | 602 | void 603 | merge_model(long lower, long mid, long upper) 604 | { 605 | long i, j, k; 606 | int temp; 607 | 608 | merge_copy(jsim_model_array, lower, mid); 609 | i = 0; 610 | j = mid + 1; 611 | k = lower; 612 | while ((i <= mid - lower) && (j <= upper)) 613 | { 614 | temp = strcmp(((modeldata *) (*(temp_array + i)))->name, 615 | ((modeldata *) (*(jsim_model_array + j)))->name); 616 | if (temp == 0) 617 | { 618 | *(jsim_model_array + k) = *(temp_array + i); 619 | k++; i++; 620 | *(jsim_model_array + k) = *(jsim_model_array + j); 621 | k++; j++; 622 | } 623 | else if (temp < 0) 624 | { 625 | *(jsim_model_array + k) = *(temp_array + i); 626 | k++; i++; 627 | } 628 | else 629 | { 630 | *(jsim_model_array + k) = *(jsim_model_array + j); 631 | k++; j++; 632 | } 633 | } /* while */ 634 | 635 | if (i <= mid - lower) 636 | while (i <= mid - lower) 637 | { 638 | *(jsim_model_array + k) = *(temp_array + i); 639 | k++; i++; 640 | } 641 | 642 | } /* merge_model */ 643 | 644 | 645 | void 646 | get_model_array() 647 | { 648 | int i; 649 | modeldata *temp_model; 650 | 651 | if (mod_count <= 0) return; 652 | 653 | jsim_model_array = (long *) mycalloc(mod_count, sizeof(long)); 654 | 655 | i = 0; 656 | temp_model = jsim_model; 657 | while (temp_model != NULL) 658 | { 659 | *(jsim_model_array + i) = (long) temp_model; 660 | i++; 661 | temp_model = temp_model->next_model; 662 | } 663 | 664 | if (mod_count > 1) 665 | { 666 | temp_array = (long *) mycalloc(mod_count/2 + 1, sizeof(long)); 667 | sort_model(0, mod_count - 1); 668 | free((char *) temp_array); 669 | } 670 | 671 | } /* get_model_array */ 672 | 673 | 674 | modeldata * 675 | search_model(char *name) 676 | { 677 | int lower, mid, upper; 678 | int temp; 679 | 680 | lower = 0; 681 | upper = mod_count - 1; 682 | 683 | while (lower <= upper) 684 | { 685 | mid = (lower + upper)/2; 686 | temp = strcmp(name, 687 | ((modeldata *) (*(jsim_model_array + mid)))->name); 688 | if (temp == 0) 689 | return((modeldata *) (*(jsim_model_array + mid))); 690 | else if (temp < 0) upper = mid - 1; 691 | else lower = mid + 1; 692 | } 693 | return(NULL); 694 | 695 | } /* search_model */ 696 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/subckt.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | #include 21 | #include 22 | 23 | long name; 24 | modeldata *modptr; 25 | 26 | 27 | void 28 | read_sub_def() 29 | { 30 | read_error = read_string("subckt definition name"); 31 | if (read_error != OK) 32 | { 33 | printf("## Error -- bad subcircuit definition\n"); 34 | no_go = TRUE; 35 | return; 36 | } 37 | 38 | dev_name = new_string(tempstring); 39 | intptr[0] = 0; 40 | while ((read_error = read_long(nodeptr+intptr[0], "node", TRUE)) 41 | == OK) 42 | intptr[0]++; 43 | if (intptr[0] < 1) 44 | { 45 | printf("## Error -- bad subcircuit definition,"); 46 | printf(" too few node\n"); 47 | no_go = TRUE; 48 | free(dev_name); 49 | return; 50 | } 51 | 52 | new_sub_def(dev_name, intptr, nodeptr); 53 | 54 | } /* read_sub_def */ 55 | 56 | 57 | void 58 | new_sub_def(char *name, long *intptr, long *nodeptr) 59 | { 60 | int i; 61 | sub_def *temp_sub_def; 62 | 63 | temp_sub_def = (sub_def *) mycalloc(1, sizeof(sub_def)); 64 | temp_sub_def->name = name; 65 | temp_sub_def->no_node = *intptr; 66 | temp_sub_def->node_list = (int *) mycalloc(*intptr, sizeof(int)); 67 | for (i = 0; i < *intptr; i++) 68 | *(temp_sub_def->node_list + i) = *(nodeptr + i); 69 | temp_sub_def->the_sub_ckt = temp_sub_def->the_sub_tail = NULL; 70 | temp_sub_def->sub_dev_count = 0; 71 | temp_sub_def->sub_dev_array = NULL; 72 | temp_sub_def->parent = NULL; 73 | temp_sub_def->next_sub = NULL; 74 | temp_sub_def->sub_sub = temp_sub_def->sub_sub_tail = NULL; 75 | temp_sub_def->sub_sub_count = 0; 76 | temp_sub_def->sub_sub_array = NULL; 77 | 78 | if (current_sub_def == NULL) 79 | { 80 | if (sub_def_tree == NULL) 81 | { 82 | sub_def_tree = temp_sub_def; 83 | sub_def_tail = temp_sub_def; 84 | } 85 | else 86 | { 87 | sub_def_tail->next_sub = temp_sub_def; 88 | sub_def_tail = temp_sub_def; 89 | } 90 | sub_def_count++; 91 | } 92 | else 93 | { 94 | temp_sub_def->parent = current_sub_def; 95 | if (current_sub_def->sub_sub == NULL) 96 | { 97 | current_sub_def->sub_sub = temp_sub_def; 98 | current_sub_def->sub_sub_tail = temp_sub_def; 99 | } 100 | else 101 | { 102 | current_sub_def->sub_sub_tail->next_sub = temp_sub_def; 103 | current_sub_def->sub_sub_tail = temp_sub_def; 104 | } 105 | current_sub_def->sub_sub_count++; 106 | } 107 | current_sub_def = temp_sub_def; 108 | 109 | } /* new_sub_def */ 110 | 111 | 112 | void 113 | read_sub_ckt() 114 | { 115 | int bad_dev = FALSE; 116 | 117 | read_error = read_string("subckt definition name"); 118 | if (read_error != OK) 119 | { 120 | printf("## Error -- bad subckt call\n"); 121 | no_go = TRUE; 122 | bad_dev = TRUE; 123 | } 124 | else modptr = (modeldata *) new_string(tempstring); 125 | 126 | intptr[0] = 0; 127 | while ((read_error = read_long(nodeptr+intptr[0], "node", TRUE)) 128 | == OK) 129 | intptr[0]++; 130 | 131 | if (bad_dev == FALSE) 132 | { 133 | if (current_sub_def == NULL) 134 | subckt_to_devlist((long) dev_name, SUB_C, nodeptr, intptr, modptr); 135 | else 136 | subckt_to_deftree(dev_name, SUB_C, nodeptr, intptr, modptr); 137 | } 138 | 139 | } /* read_sub_ckt */ 140 | 141 | 142 | device * 143 | subckt_to_devlist(long name, int type, long *nodeptr, long *intptr, 144 | modeldata *modptr) 145 | { 146 | switch (type) 147 | { 148 | case SUB_C : 149 | 150 | return(add_sub_ckt(name, *intptr, nodeptr, (char *) modptr)); 151 | 152 | } 153 | 154 | return(NULL); 155 | 156 | } /* subckt_to_devlist */ 157 | 158 | 159 | device * 160 | subckt_to_deftree(char *dev_name, int type, long *nodeptr, long *intptr, 161 | modeldata *modptr) 162 | { 163 | long name; 164 | 165 | name = (long) dev_name; 166 | 167 | switch (type) 168 | { 169 | case SUB_C : 170 | 171 | return(add_sub_ckt(name, *intptr, nodeptr, (char *) modptr)); 172 | 173 | } 174 | 175 | return(NULL); 176 | 177 | } /* subckt_to_deftree */ 178 | 179 | 180 | device *subckt_call[100]; 181 | sub_def *subckt_def_call[100]; 182 | int current_call; 183 | subnode_to_node *subnode_buffer; 184 | int sub_buffer_index; 185 | 186 | 187 | int 188 | scan_node(int node) 189 | { 190 | int i; 191 | 192 | i = 0; 193 | while (i < current_sub_def->no_node) 194 | { 195 | if (*(current_sub_def->node_list + i) == node) return(i+1); 196 | i++; 197 | } 198 | 199 | return(0); 200 | 201 | } /* scan_node */ 202 | 203 | 204 | device * 205 | add_sub(char *name, int type, char *data) 206 | { 207 | device *temp; 208 | 209 | temp = (device *) mycalloc(1, sizeof(device)); 210 | temp->name = (long) name; 211 | temp->type = type; 212 | temp->data = data; 213 | temp->next_dev = NULL; 214 | 215 | if (current_sub_def->the_sub_ckt == NULL) 216 | { 217 | current_sub_def->the_sub_ckt = temp; 218 | current_sub_def->the_sub_tail = temp; 219 | } 220 | else 221 | { 222 | current_sub_def->the_sub_tail->next_dev = temp; 223 | current_sub_def->the_sub_tail = temp; 224 | } 225 | current_sub_def->sub_dev_count++; 226 | 227 | return(temp); 228 | 229 | } /* add_sub */ 230 | 231 | 232 | device * 233 | add_sub_ckt(long name, long no_node, long *node_list, char *sub_def_name) 234 | { 235 | int i; 236 | char *data; 237 | dev_sub_ckt *temp; 238 | sub_sub_ckt *temp_sub; 239 | 240 | if (current_sub_def == NULL) 241 | { 242 | temp = (dev_sub_ckt *) mycalloc(1, sizeof(dev_sub_ckt)); 243 | 244 | temp->sub_def_name = sub_def_name; 245 | temp->no_node = no_node; 246 | temp->node_list = (long *) mycalloc(no_node, sizeof(long)); 247 | for (i = 0; i < no_node; i++) 248 | *(temp->node_list + i) = *(node_list + i); 249 | 250 | data = (char *) temp; 251 | return(add_dev(name, SUB_C, data)); 252 | } 253 | else 254 | { 255 | temp_sub = (sub_sub_ckt *) mycalloc(1, sizeof(sub_sub_ckt)); 256 | 257 | temp_sub->sub_def_name = sub_def_name; 258 | temp_sub->no_node = no_node; 259 | temp_sub->node_list = (long *) mycalloc(no_node, sizeof(long)); 260 | temp_sub->temp_node_list = (long *) mycalloc(no_node, sizeof(long)); 261 | temp_sub->node_node = (long *) mycalloc(no_node, sizeof(long)); 262 | for (i = 0; i < no_node; i++) 263 | { 264 | *(temp_sub->node_list + i) = *(node_list + i); 265 | *(temp_sub->node_node + i) = scan_node(*(node_list + i)); 266 | } 267 | 268 | data = (char *) temp_sub; 269 | return(add_sub((char *) name, SUB_C, data)); 270 | } 271 | 272 | } /* add_sub_ckt */ 273 | 274 | 275 | long 276 | getnode_subnode(int subnode, int subnode_index) 277 | { 278 | int i; 279 | 280 | if (subnode == 0) return(0); 281 | 282 | if (subnode_index <= 0) 283 | { 284 | i = 0; 285 | while (i <= sub_buffer_index) 286 | { 287 | if ((subnode_buffer + i)->subnode == subnode) 288 | return((subnode_buffer + i)->node); 289 | i++; 290 | } 291 | sub_buffer_index++; 292 | subnode_count--; 293 | (subnode_buffer + sub_buffer_index)->subnode = subnode; 294 | (subnode_buffer + sub_buffer_index)->node = subnode_count; 295 | return(subnode_count); 296 | } 297 | else 298 | { 299 | subnode_index--; 300 | if (current_call > 0) 301 | return(*(((sub_sub_ckt *) 302 | subckt_call[current_call]->data)->temp_node_list 303 | + subnode_index)); 304 | else 305 | return(*(((dev_sub_ckt *) 306 | subckt_call[current_call]->data)->node_list 307 | + subnode_index)); 308 | } 309 | 310 | } /* getnode_subnode */ 311 | 312 | 313 | char * 314 | get_subdev_name(char *name) 315 | { 316 | int temp_call; 317 | int temp_count; 318 | int found; 319 | device *temp_dev; 320 | 321 | temp_call = current_call; 322 | temp_count = strlen(namestring) - 1; 323 | 324 | found = FALSE; 325 | 326 | while ((found == FALSE) && (temp_call >= 0)) 327 | { 328 | temp_dev = search_dev(subckt_def_call[temp_call]->sub_dev_array, 329 | subckt_def_call[temp_call]->sub_dev_count, 330 | name); 331 | if (temp_dev != NULL) found = TRUE; 332 | else 333 | { 334 | if (temp_call > 0) 335 | { 336 | temp_count--; 337 | while (namestring[temp_count] != '_') temp_count--; 338 | } 339 | temp_call--; 340 | } 341 | } /* while */ 342 | 343 | if (temp_call < 0) return(new_string(name)); 344 | return(comb_str_seg(namestring, temp_count, name)); 345 | 346 | } /* get_subdev_name */ 347 | 348 | 349 | void 350 | do_sub_ckt() 351 | { 352 | char *sub_def_name; 353 | char *sub_ckt_name; 354 | device *temp_dev; 355 | 356 | current_sub_def = NULL; 357 | subnode_buffer = (subnode_to_node *) 358 | mycalloc(SUB_BUFFER_SIZE, sizeof(subnode_to_node)); 359 | sub_buffer_index = -1; 360 | 361 | temp_dev = sub_ckt; 362 | while (temp_dev != NULL) 363 | { 364 | current_call = 0; 365 | sub_ckt_name = (char *) temp_dev->name; 366 | sub_def_name = ((dev_sub_ckt *) temp_dev->data)->sub_def_name; 367 | 368 | subckt_def_call[0] = find_sub_def(NULL, sub_def_name); 369 | 370 | subckt_call[0] = temp_dev; 371 | temp_dev = temp_dev->next_dev; 372 | if (subckt_def_call[0] == NULL) 373 | { 374 | no_go = TRUE; 375 | printf("subckt call %s subdef %s not defined\n", 376 | sub_ckt_name, sub_def_name); 377 | } 378 | else 379 | { 380 | strcpy(namestring, sub_ckt_name); 381 | strcat(namestring, "_"); 382 | expand_sub_ckt(); 383 | } 384 | } 385 | 386 | } /* do_sub_ckt */ 387 | 388 | 389 | void 390 | expand_sub_ckt() 391 | { 392 | device *temp_dev; 393 | device *sub_to_devlist(); 394 | 395 | sub_buffer_index = -1; 396 | temp_dev = subckt_def_call[current_call]->the_sub_ckt; 397 | while (temp_dev != NULL) 398 | { 399 | sub_to_devlist((char *) temp_dev->name, temp_dev->type, 400 | temp_dev->data); 401 | temp_dev = temp_dev->next_dev; 402 | 403 | } /* while */ 404 | 405 | temp_dev = subckt_def_call[current_call]->the_sub_ckt; 406 | while (temp_dev != NULL) 407 | { 408 | if (temp_dev->type == SUB_C) 409 | { 410 | current_call++; 411 | subckt_def_call[current_call] = 412 | find_sub_def(subckt_def_call[current_call - 1], 413 | ((sub_sub_ckt *) temp_dev->data)->sub_def_name); 414 | 415 | subckt_call[current_call] = temp_dev; 416 | if (subckt_def_call[current_call] == NULL) 417 | { 418 | no_go = TRUE; 419 | printf("subckt call %s subdef %s not defined\n", 420 | (char *) temp_dev->name, 421 | ((sub_sub_ckt *) temp_dev->data)->sub_def_name); 422 | } 423 | else 424 | { 425 | strcat(namestring, (char *) temp_dev->name); 426 | strcat(namestring, "_"); 427 | expand_sub_ckt(); 428 | current_call--; 429 | namestring[strlen(namestring) - 430 | strlen((char *) temp_dev->name) - 1] = '\0'; 431 | } 432 | } /* else */ 433 | temp_dev = temp_dev->next_dev; 434 | 435 | } /* while */ 436 | 437 | } /* expand_sub_ckt */ 438 | 439 | 440 | sub_def * 441 | find_sub_def(sub_def *the_sub_def, char *name) 442 | { 443 | sub_def *temp_sub; 444 | 445 | if (the_sub_def == NULL) 446 | { 447 | temp_sub = search_sub_def(sub_def_array, sub_def_count, name); 448 | return(temp_sub); 449 | } 450 | else 451 | { 452 | temp_sub = search_sub_def(the_sub_def->sub_sub_array, 453 | the_sub_def->sub_sub_count, name); 454 | if (temp_sub != NULL) return(temp_sub); 455 | else return(find_sub_def(the_sub_def->parent, name)); 456 | } 457 | 458 | } /* find_sub_def */ 459 | 460 | 461 | device * 462 | sub_to_devlist(char *dev_name, int type, char *data) 463 | { 464 | int i; 465 | 466 | switch (type) 467 | { 468 | case RESIS : 469 | 470 | return(resissub_to_devlist(dev_name, type, data)); 471 | 472 | case CAP : 473 | 474 | return(capsub_to_devlist(dev_name, type, data)); 475 | 476 | case INDUCT : 477 | 478 | return(indsub_to_devlist(dev_name, type, data)); 479 | 480 | case DC_V : 481 | case SIN_V : 482 | case PULSE_V : 483 | case PWL_V : 484 | case NOISE_V : 485 | case V_SOURCE : 486 | return(vssub_to_devlist(dev_name, data)); 487 | 488 | case SIN_I : 489 | case PULSE_I : 490 | case PWL_I : 491 | case I_SOURCE : 492 | case NOISE_I : 493 | 494 | 495 | return(issub_to_devlist(dev_name, data)); 496 | 497 | case JJ : 498 | 499 | return(jjsub_to_devlist(dev_name, type, data)); 500 | 501 | case MUTUAL_L : 502 | 503 | return(mutsub_to_devlist(dev_name, type, data)); 504 | 505 | case TRAN_NO_LOSS : 506 | 507 | return(xlinesub_to_devlist(dev_name, type, data)); 508 | 509 | case SUB_C : 510 | 511 | for (i = 0; i < ((sub_sub_ckt *) data)->no_node; i++) 512 | { 513 | *(((sub_sub_ckt *) data)->temp_node_list + i) = 514 | getnode_subnode(*(((sub_sub_ckt *) data)->node_list + i), 515 | *(((sub_sub_ckt *) data)->node_node + i)); 516 | } 517 | return(NULL); 518 | 519 | } /* switch */ 520 | 521 | return(NULL); 522 | 523 | } /* sub_to_devlist */ 524 | -------------------------------------------------------------------------------- /vendor/jsim/jsimtxt/topology.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | #include "jsim.h" 19 | #include "extern.h" 20 | 21 | 22 | int 23 | hash_node(int node) 24 | { 25 | if (node == 0) return(RANGE); 26 | if (node > 0) return(node % RANGE); 27 | return((0 - node) % RANGE); 28 | 29 | } /* hash_node */ 30 | 31 | 32 | branch_marker * 33 | add_bmarker() 34 | { 35 | branch_marker *temp_marker; 36 | 37 | temp_marker = (branch_marker *) mycalloc(1, sizeof(branch_marker)); 38 | temp_marker->marker = 0; 39 | 40 | return(temp_marker); 41 | 42 | } /* add_bmarker */ 43 | 44 | 45 | int 46 | add_node(int node, long name, int devtype, int nodetype, 47 | branch_marker *bmarker) 48 | { 49 | int r; 50 | node_to_eqn *temp; 51 | branch_list *temp_branch; 52 | 53 | temp_branch = (branch_list *) mycalloc(1, sizeof(branch_list)); 54 | temp_branch->name = name; 55 | temp_branch->devtype = devtype; 56 | temp_branch->nodetype = nodetype; 57 | temp_branch->bmarker = bmarker; 58 | temp_branch->next_branch = NULL; 59 | 60 | r = hash_node(node); 61 | 62 | if (node_map[r] == NULL) 63 | { 64 | if (r < RANGE) 65 | { 66 | eqn_count++; 67 | node_count++; 68 | } 69 | 70 | node_map[r] = (node_to_eqn *) mycalloc(1, sizeof(node_to_eqn)); 71 | if (r < RANGE) 72 | { 73 | node_map[r]->n_eq = eqn_count; 74 | node_map[r]->node = node; 75 | } 76 | else 77 | { 78 | node_map[r]->n_eq = GROUND; 79 | node_map[r]->node = node; 80 | } 81 | node_map[r]->marker = 0; 82 | node_map[r]->branch = node_map[r]->branch_tail = temp_branch; 83 | node_map[r]->next_node = NULL; 84 | 85 | if ((nodetype == PLUS_NODE) || (nodetype == PLUS_C_NODE)) 86 | bmarker->pnode = (long) node_map[r]; 87 | else bmarker->mnode = (long) node_map[r]; 88 | 89 | return(node_map[r]->n_eq); 90 | } 91 | 92 | temp = node_map[r]; 93 | 94 | if (temp->node == node) 95 | { 96 | temp->branch_tail->next_branch = temp_branch; 97 | temp->branch_tail = temp_branch; 98 | 99 | if ((nodetype == PLUS_NODE) || (nodetype == PLUS_C_NODE)) 100 | bmarker->pnode = (long) temp; 101 | else bmarker->mnode = (long) temp; 102 | 103 | return(temp->n_eq); 104 | } 105 | 106 | while (temp->next_node != NULL) 107 | { 108 | if (temp->next_node->node == node) 109 | { 110 | temp->next_node->branch_tail->next_branch = temp_branch; 111 | temp->next_node->branch_tail = temp_branch; 112 | 113 | if ((nodetype == PLUS_NODE) || (nodetype == PLUS_C_NODE)) 114 | bmarker->pnode = (long) temp->next_node; 115 | else bmarker->mnode = (long) temp->next_node; 116 | 117 | return(temp->next_node->n_eq); 118 | } 119 | 120 | temp = temp->next_node; 121 | } 122 | 123 | eqn_count++; 124 | node_count++; 125 | 126 | temp->next_node = (node_to_eqn *) mycalloc(1, sizeof(node_to_eqn)); 127 | temp = temp->next_node; 128 | 129 | temp->n_eq = eqn_count; 130 | temp->node = node; 131 | temp->marker = 0; 132 | temp->branch = temp->branch_tail = temp_branch; 133 | temp->next_node = NULL; 134 | 135 | if ((nodetype == PLUS_NODE) || (nodetype == PLUS_C_NODE)) 136 | bmarker->pnode = (long) temp; 137 | else bmarker->mnode = (long) temp; 138 | 139 | return(temp->n_eq); 140 | 141 | } /* add_node */ 142 | 143 | 144 | void 145 | clear_marker() 146 | { 147 | int i; 148 | node_to_eqn *temp; 149 | branch_list *temp_branch; 150 | 151 | for (i = 0; i <= RANGE; i++) 152 | { 153 | temp = node_map[i]; 154 | 155 | while (temp != NULL) 156 | { 157 | temp->marker = 0; 158 | temp_branch = temp->branch; 159 | 160 | while (temp_branch != NULL) 161 | { 162 | temp_branch->bmarker->marker = 0; 163 | temp_branch = temp_branch->next_branch; 164 | } 165 | temp = temp->next_node; 166 | } /* while */ 167 | } /* for */ 168 | 169 | } /* clear_marker */ 170 | 171 | 172 | void 173 | cutset_check() 174 | { 175 | 176 | int i; 177 | int capacitor; 178 | int others; 179 | int element_count; 180 | realname_name *temp_name; 181 | node_to_eqn *temp; 182 | branch_list *temp_branch; 183 | 184 | 185 | for (i = 0; i <= RANGE; i++) 186 | { 187 | temp = node_map[i]; 188 | while (temp != NULL) 189 | { 190 | capacitor = FALSE; 191 | others = FALSE; 192 | element_count = 0; 193 | temp_branch = temp->branch; 194 | 195 | while (temp_branch != NULL) 196 | { 197 | switch (temp_branch->devtype) 198 | { 199 | case I_SOURCE : 200 | case SIN_I : 201 | case PULSE_I : 202 | case PWL_I : 203 | case NOISE_I : break; 204 | 205 | case CAP : capacitor = TRUE; 206 | break; 207 | default : others = TRUE; 208 | break; 209 | } 210 | 211 | element_count++; 212 | temp_branch = temp_branch->next_branch; 213 | 214 | } /* while */ 215 | 216 | if (element_count == 1) 217 | { 218 | temp_name = search_name(temp->branch->name); 219 | printf("## Error -- node %1d has only one", temp->node); 220 | printf(" element %s attached\n", temp_name->real_name); 221 | no_go = TRUE; 222 | } 223 | 224 | if (others == FALSE) 225 | { 226 | if (capacitor == FALSE) 227 | { 228 | printf("## Error -- node %1d has only current", temp->node); 229 | printf(" source(s) attached\n"); 230 | no_go = TRUE; 231 | } 232 | else 233 | { 234 | printf("## Warning -- node %1d has only cap(s)", temp->node); 235 | printf(" and/or current source(s) attached\n"); 236 | warned = TRUE; 237 | } 238 | } 239 | 240 | temp = temp->next_node; 241 | } /* while */ 242 | } /* for */ 243 | 244 | } /* cutset_check */ 245 | 246 | 247 | void 248 | trace_subgraph(node_to_eqn *nodeptr, int source_only) 249 | { 250 | branch_list *temp_branch; 251 | node_to_eqn *temp2; 252 | realname_name *temp_name; 253 | 254 | 255 | temp_branch = nodeptr->branch; 256 | 257 | while (temp_branch != NULL) 258 | { 259 | if (((source_type(temp_branch->devtype) == V_SOURCE) || 260 | ((source_only == FALSE) && 261 | ((temp_branch->devtype == INDUCT) || 262 | (temp_branch->devtype == LOSSLESS_LINE)))) && 263 | (temp_branch->bmarker->marker == 0)) 264 | { 265 | 266 | temp_branch->bmarker->marker = 1; 267 | 268 | if (node_type(temp_branch->nodetype) == POSITIVE) 269 | temp2 = (node_to_eqn *) temp_branch->bmarker->mnode; 270 | else temp2 = (node_to_eqn *) temp_branch->bmarker->pnode; 271 | 272 | 273 | if (temp2->marker == 1) 274 | { 275 | temp_name = search_name(temp_branch->name); 276 | if (source_only == TRUE) 277 | { 278 | printf("## Error -- voltage source loop found"); 279 | no_go = TRUE; 280 | } 281 | else 282 | { 283 | printf("## Warning -- voltage source/inductor loop found"); 284 | warned = TRUE; 285 | } 286 | printf(" including %s\n", temp_name->real_name); 287 | } 288 | 289 | temp2->marker = 1; 290 | 291 | trace_subgraph(temp2, source_only); 292 | 293 | } 294 | 295 | temp_branch = temp_branch->next_branch; 296 | 297 | } /* while */ 298 | 299 | } /* trace_subgraph */ 300 | 301 | 302 | void 303 | sourceloop_check(int source_only) 304 | { 305 | int i; 306 | node_to_eqn *temp, *temp2; 307 | branch_list *temp_branch; 308 | 309 | for(i = 0; i <= RANGE; i++) 310 | { 311 | temp = node_map[i]; 312 | while (temp != NULL) 313 | { 314 | 315 | if (temp->marker == 1) 316 | { 317 | temp = temp->next_node; 318 | continue; 319 | } 320 | 321 | temp_branch = temp->branch; 322 | 323 | while (temp_branch != NULL) 324 | { 325 | 326 | if (((source_type(temp_branch->devtype) == V_SOURCE) || 327 | ((source_only == FALSE) && 328 | ((temp_branch->devtype == INDUCT) || 329 | (temp_branch->devtype == LOSSLESS_LINE)))) && 330 | (temp_branch->bmarker->marker == 0)) 331 | { 332 | 333 | temp_branch->bmarker->marker = 1; 334 | 335 | temp->marker = 1; 336 | 337 | if (node_type(temp_branch->nodetype) == POSITIVE) 338 | temp2 = (node_to_eqn *) temp_branch->bmarker->mnode; 339 | else temp2 = (node_to_eqn *) temp_branch->bmarker->pnode; 340 | temp2->marker = 1; 341 | 342 | trace_subgraph(temp, source_only); 343 | trace_subgraph(temp2, source_only); 344 | 345 | break; 346 | } 347 | 348 | temp_branch = temp_branch->next_branch; 349 | 350 | } /* while */ 351 | 352 | temp = temp->next_node; 353 | 354 | } /* while */ 355 | } /* for */ 356 | 357 | clear_marker(); 358 | 359 | } /* sourceloop_check */ 360 | 361 | 362 | void 363 | trace_connect(node_to_eqn *nodeptr, int dcpath_only) 364 | { 365 | branch_list *temp_branch; 366 | node_to_eqn *temp2; 367 | 368 | temp_branch = nodeptr->branch; 369 | 370 | while (temp_branch != NULL) 371 | { 372 | if ((dcpath_only == FALSE) || 373 | (is_dc_device(temp_branch->devtype) == TRUE)) 374 | { 375 | 376 | if (node_type(temp_branch->nodetype) == POSITIVE) 377 | temp2 = (node_to_eqn *) temp_branch->bmarker->mnode; 378 | else temp2 = (node_to_eqn *) temp_branch->bmarker->pnode; 379 | 380 | if (temp2->marker == 0) 381 | { 382 | temp2->marker = 1; 383 | trace_connect(temp2, dcpath_only); 384 | } 385 | 386 | } 387 | 388 | temp_branch = temp_branch->next_branch; 389 | 390 | } /* while */ 391 | 392 | } /* trace_connect */ 393 | 394 | 395 | void 396 | ground_check(int dcpath_only) 397 | { 398 | int i; 399 | node_to_eqn *temp, *temp2; 400 | branch_list *temp_branch; 401 | 402 | temp = node_map[RANGE]; 403 | if (temp != NULL) 404 | { 405 | temp->marker = 1; 406 | temp_branch = temp->branch; 407 | while (temp_branch != NULL) 408 | { 409 | if ((dcpath_only == FALSE) || 410 | (is_dc_device(temp_branch->devtype) == TRUE)) 411 | { 412 | if (node_type(temp_branch->nodetype) == POSITIVE) 413 | temp2 = (node_to_eqn *) temp_branch->bmarker->mnode; 414 | else 415 | temp2 = (node_to_eqn *) temp_branch->bmarker->pnode; 416 | 417 | if (temp2->marker == 0) 418 | { 419 | temp2->marker = 1; 420 | trace_connect(temp2, dcpath_only); 421 | } 422 | } 423 | 424 | temp_branch = temp_branch->next_branch; 425 | 426 | } /* while */ 427 | 428 | } /* if */ 429 | 430 | 431 | for (i = 0; i < RANGE; i++) 432 | { 433 | temp = node_map[i]; 434 | while (temp != NULL) 435 | { 436 | if (temp->marker == 0) 437 | { 438 | if (dcpath_only == FALSE) 439 | { 440 | printf("## Error -- node %1d has no path to ground\n", 441 | temp->node); 442 | no_go = TRUE; 443 | } 444 | else 445 | { 446 | printf("## Warning -- node %1d has no dc path to ground\n", 447 | temp->node); 448 | warned = TRUE; 449 | } 450 | } 451 | 452 | temp = temp->next_node; 453 | } /* while */ 454 | } /* for */ 455 | 456 | clear_marker(); 457 | 458 | } /* ground_check */ 459 | 460 | -------------------------------------------------------------------------------- /vendor/jsim/main.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | 18 | /************************************************************************* 19 | * 20 | * jsim [-options] [filenames] [-options] [filenames] ... 21 | * 22 | * Options can be d, r, or nothing, following a '-'. 23 | * d toggle debugging, which dumps a file jsim.dbg (initially off). 24 | * r toggle use of a rawfile jsim.raw for output (initially off). 25 | * - read the standard input. 26 | * 27 | * Otherwise, tokens on the command line are assumed to be file names 28 | * to read for input. If no such tokens are found, the standard input 29 | * is read. 30 | * 31 | * The options operate on files listed to the right of the option 32 | * list, and are active until changed with another invocation. If 33 | * no files are listed, the options are read before the standard 34 | * input is read. 35 | * 36 | * examples: 37 | * 38 | * jsim file1 -d file2 -d file3 39 | * will dump debug information while simulating file2. 40 | * 41 | * jsim file1 -rd - file3 56 | #include 57 | 58 | #if __STDC__ 59 | static void run_jsim(void); 60 | static void do_opts(char*); 61 | #else 62 | static void run_jsim(); 63 | static void do_opts(); 64 | #endif 65 | 66 | FILE *fp; 67 | 68 | 69 | int 70 | main(int argc, char **argv) 71 | { 72 | int i; 73 | int tried = FALSE; 74 | 75 | #if (__TURBOC__) 76 | _control87(0xffff,0x003f); 77 | #endif 78 | 79 | jsim_dbg = FALSE; 80 | jsim_raw = FALSE; 81 | 82 | for (i = 1; i < argc; i++) { 83 | if (*argv[i] == '-') { 84 | if (*(argv[i]+1) == '\0') { 85 | add_input_file("stdin", stdin); 86 | if (jsim_raw) 87 | printf("\nReading stdin\n"); 88 | run_jsim(); 89 | tried = TRUE; 90 | } 91 | else 92 | do_opts(argv[i]+1); 93 | } 94 | else { 95 | if (open_input_file(argv[i])) { 96 | printf("\nCan't open %s\n",argv[i]); 97 | } else { 98 | if (jsim_raw) 99 | printf("\nReading %s\n",argv[i]); 100 | run_jsim(); 101 | } 102 | tried = TRUE; 103 | } 104 | } 105 | if (tried == FALSE) { 106 | add_input_file("stdin", stdin); 107 | 108 | if (jsim_raw) 109 | printf("\nReading stdin\n"); 110 | run_jsim(); 111 | } 112 | 113 | return (0); 114 | } /* main */ 115 | 116 | 117 | static void 118 | run_jsim() 119 | { 120 | FILE *fopen(); 121 | struct timeval now; 122 | double t; 123 | 124 | 125 | init_global(); 126 | read_deck(); 127 | process_deck(); 128 | deckerror_check(); 129 | topology_check(); 130 | free_space(); 131 | 132 | if (stop_time < 0.0) 133 | { 134 | printf("## Error -- no transient analysis specified\n"); 135 | no_go = TRUE; 136 | } 137 | 138 | if ((no_go == FALSE) && 139 | ((warned == FALSE) || (igwarn_no_go == TRUE))) 140 | { 141 | setup_device(); 142 | setup_matrix(); 143 | get_breakpoint(); 144 | 145 | gettimeofday(&now, NULL); 146 | t = now.tv_sec + now.tv_usec*1e-6; 147 | time_loop(hptr); 148 | gettimeofday(&now, NULL); 149 | t -= now.tv_sec + now.tv_usec*1e-6; 150 | print_stat_LU(my_matrix); 151 | printf("\nSimulation ran %.2lf seconds.\n",-t); 152 | 153 | /* 154 | printf("lu op count %d\n", lu_opcount); 155 | */ 156 | 157 | } 158 | 159 | else if (no_go == TRUE) 160 | printf("\n\n#### JOB ABORTED due to error in input deck\n"); 161 | 162 | else if (warned == TRUE) 163 | printf("\n\n#### JOB ABORTED due to warning in input deck\n"); 164 | 165 | } /* run_jsim */ 166 | 167 | 168 | static void 169 | do_opts(char *s) 170 | { 171 | char *c; 172 | 173 | for (c = s; *c; c++) { 174 | if (*c == 'd') { 175 | jsim_dbg ^= 1; 176 | break; 177 | } 178 | } 179 | for (c = s; *c; c++) { 180 | if (*c == 'r') { 181 | jsim_raw ^= 1; 182 | break; 183 | } 184 | } 185 | 186 | } /* do_opts */ 187 | -------------------------------------------------------------------------------- /vendor/jsim/main_n.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * JSIM Release 2.0 10/24/92 4 | * 5 | * JSIM is a simulator for circuits containing Josephson Junctions. 6 | * 7 | * Author: Emerson Fang, 1991 8 | * University of California, Berkeley 9 | * Dept. of Electrical Engineering and Computer Sciences 10 | * Cryoelectronics Group, Professor Ted Van Duzer 11 | * 12 | * 13 | * Cleanup Crew: Jay Fleischman (jef@swordfish.berkeley.edu) 14 | * Steve Whiteley (stevew@landau.conductus.com) 15 | * 16 | *************************************************************************/ 17 | /** noise hack by J Satchell, DRA Malvern **/ 18 | /************************************************************************* 19 | * 20 | * jsim [-options] [filenames] [-options] [filenames] ... 21 | * 22 | * Options can be d, r, or nothing, following a '-'. 23 | * d toggle debugging, which dumps a file jsim.dbg (initially off). 24 | * r toggle use of a rawfile jsim.raw for output (initially off). 25 | * - read the standard input. 26 | * 27 | * Otherwise, tokens on the command line are assumed to be file names 28 | * to read for input. If no such tokens are found, the standard input 29 | * is read. 30 | * 31 | * The options operate on files listed to the right of the option 32 | * list, and are active until changed with another invocation. If 33 | * no files are listed, the options are read before the standard 34 | * input is read. 35 | * 36 | * examples: 37 | * 38 | * jsim file1 -d file2 -d file3 39 | * will dump debug information while simulating file2. 40 | * 41 | * jsim file1 -rd - file3 56 | #include 57 | 58 | #include 59 | 60 | #if __STDC__ 61 | static void run_jsim(void); 62 | static void do_opts(char*); 63 | #else 64 | static void run_jsim(); 65 | static void do_opts(); 66 | #endif 67 | 68 | FILE *fp; 69 | 70 | 71 | int 72 | main(argc,argv) 73 | 74 | int argc; 75 | char **argv; 76 | { 77 | int i; 78 | int tried = FALSE; 79 | struct timeb now; 80 | int seed; 81 | 82 | #if (__TURBOC__) 83 | _control87(0xffff,0x003f); 84 | #endif 85 | /* use real time to set random number generator to non repeatable state */ 86 | ftime(&now); 87 | seed = now.time*1000+now.millitm; 88 | #ifdef NORANDOM 89 | srand(seed); 90 | #else 91 | srandom(seed); 92 | #endif 93 | jsim_dbg = FALSE; 94 | jsim_raw = FALSE; 95 | jsim_mout = FALSE; 96 | 97 | for (i = 1; i < argc; i++) { 98 | if (*argv[i] == '-') { 99 | if (*(argv[i]+1) == '\0') { 100 | add_input_file("stdin", stdin); 101 | if (jsim_raw) 102 | printf("\nReading stdin\n"); 103 | run_jsim(); 104 | tried = TRUE; 105 | } 106 | else 107 | if (*(argv[i]+1) == 'm') { 108 | jsim_mout ^= 1; 109 | jsim_raw = FALSE; 110 | mfilename = argv[i+1]; /* argv should not vanish during program execution */ 111 | printf("Filename for exported variables: %s\n", mfilename); 112 | i++; 113 | } else { 114 | do_opts(argv[i]+1); 115 | } 116 | } 117 | else { 118 | if (open_input_file(argv[i])) { 119 | printf("\nCan't open %s\n",argv[i]); 120 | } else { 121 | if (jsim_raw) 122 | printf("\nReading %s\n",argv[i]); 123 | run_jsim(); 124 | } 125 | tried = TRUE; 126 | } 127 | } 128 | if (tried == FALSE) { 129 | add_input_file("stdin", stdin); 130 | if (jsim_raw) 131 | printf("\nReading stdin\n"); 132 | run_jsim(); 133 | } 134 | 135 | } /* main */ 136 | 137 | /* Forward declarations (perhaps move to .h file one day?) */ 138 | void init_global(); 139 | void read_deck(); 140 | void process_deck(); 141 | void deckerror_check(); 142 | void topology_check(); 143 | void free_space(); 144 | void print_header(FILE *fp); 145 | 146 | void setup_device(); 147 | void setup_matrix(); 148 | void get_breakpoint(); 149 | 150 | void time_loop(double *hptr); 151 | 152 | void print_stat_LU(matrix A); 153 | 154 | static void 155 | run_jsim() 156 | 157 | { 158 | FILE *fopen(); 159 | struct timeb now; 160 | long t; 161 | 162 | init_global(); 163 | read_deck(); 164 | process_deck(); 165 | deckerror_check(); 166 | topology_check(); 167 | free_space(); 168 | 169 | if (jsim_mout) { 170 | mfile = fopen(mfilename, "w"); 171 | if (!mfile) { 172 | printf("## Error -- cannot open output file: %s\n", mfilename); 173 | no_go = TRUE; 174 | } else { 175 | print_header(mfile); 176 | } 177 | } else { 178 | print_header(stdout); 179 | } 180 | 181 | if (stop_time < 0.0) 182 | { 183 | printf("## Error -- no transient analysis specified\n"); 184 | no_go = TRUE; 185 | } 186 | 187 | if ((no_go == FALSE) && 188 | ((warned == FALSE) || (igwarn_no_go == TRUE))) 189 | { 190 | setup_device(); 191 | setup_matrix(); 192 | get_breakpoint(); 193 | 194 | ftime(&now); 195 | t = now.time*1000 + now.millitm; 196 | time_loop(hptr); 197 | ftime(&now); 198 | t -= now.time*1000 + now.millitm; 199 | print_stat_LU(my_matrix); 200 | printf("\nSimulation ran %.2f seconds.\n",-t/1000.0); 201 | printf("This Stochastic extension to JSIM bought to you by\n"); 202 | printf("Julian Satchell, DRA(Malvern), UK. \n"); 203 | /* 204 | printf("lu op count %d\n", lu_opcount); 205 | */ 206 | 207 | } 208 | 209 | else if (no_go == TRUE) 210 | printf("\n\n#### JOB ABORTED due to error in input deck\n"); 211 | 212 | else if (warned == TRUE) 213 | printf("\n\n#### JOB ABORTED due to warning in input deck\n"); 214 | 215 | } /* run_jsim */ 216 | 217 | 218 | static void 219 | do_opts(s) 220 | 221 | char *s; 222 | { 223 | char *c; 224 | 225 | for (c = s; *c; c++) { 226 | if (*c == 'd') { 227 | jsim_dbg ^= 1; 228 | break; 229 | } 230 | } 231 | for (c = s; *c; c++) { 232 | if (*c == 'r') { 233 | if (!jsim_mout) jsim_raw ^= 1; 234 | break; 235 | } 236 | } 237 | 238 | } /* do_opts */ 239 | 240 | 241 | -------------------------------------------------------------------------------- /vendor/jsim/manual.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldlogix/jsim/ba1aa007dc1798cecf6ce4862f3ba6e930aa5f47/vendor/jsim/manual.dvi -------------------------------------------------------------------------------- /vendor/jsim/manual.ms: -------------------------------------------------------------------------------- 1 | .ps 12 2 | .nr PS 12 3 | .vs 14 4 | .nr VS 14 5 | .ND 6 | .EQ 7 | delim $$ 8 | gsize 12 9 | gfont R 10 | define hbar '{ h back 70 up 35 - ~ }' 11 | .EN 12 | .TL 13 | JSIM Preliminary Version User's Guide 14 | .AU 15 | E. S. Fang and T. Van Duzer 16 | .AI 17 | Department of Electrical Engineering and Computer Science 18 | University of California 19 | Berkeley, CA 94720 20 | .sp 21 | .NH 22 | Introduction 23 | .PP 24 | JSIM (Josephson SIMulator) is a circuit simulation program for 25 | Josephson circuits. 26 | Circuits may contain resistors, capacitors, inductors, mutual 27 | inductors, independent voltage and current sources, lossless 28 | transmission lines and 29 | Josephson junctions. 30 | At present time, only transient analysis is allowed. 31 | .PP 32 | The input format of JSIM is quite similar to SPICE. 33 | If you are not familiar with SPICE, it is recommended that 34 | you read the SPICE user guide also. 35 | .NH 36 | Circuit Description 37 | .NH 2 38 | Resistors 39 | .RS 40 | .RS 41 | .LP 42 | General form : RXXXX N1 N2 VALUE 43 | .LP 44 | Example : RC1 12 9 1KOHM 45 | .RE 46 | .RE 47 | .NH 2 48 | Capacitors 49 | .RS 50 | .RS 51 | .LP 52 | General form : CXXXX N1 N2 VALUE 53 | .LP 54 | Example : C1 10 11 1PF 55 | .LP 56 | Initial value may be specified, but currently it is 57 | ignored. This applies to ALL initial values. 58 | .RE 59 | .RE 60 | .NH 2 61 | Inductors 62 | .RS 63 | .RS 64 | .LP 65 | General form : LXXXX N1 N2 VALUE 66 | .LP 67 | Example : L2 1 0 2.3PH FCHECK 68 | .LP 69 | If FCHECK (flux check) is specified, 70 | JSIM will keep track of the change of 71 | flux through the inductor. It is recommended particularly for 72 | phase mode circuit. In each superconductive loop, at least 73 | one inductor should be considered for FCHECK option. 74 | .RE 75 | .RE 76 | .NH 2 77 | Mutual Inductors 78 | .RS 79 | .RS 80 | .LP 81 | General form : KXXXX LXXXX LYYYY VALUE 82 | .LP 83 | Example : K1 L1 L2 0.9 84 | .RE 85 | .RE 86 | .NH 2 87 | Independent Voltage Sources 88 | .NH 3 89 | Sinusoidal Sources 90 | .RS 91 | .RS 92 | .LP 93 | General form : VXXXX N1 N2 SIN(VO VA FREQ TD THETA) 94 | .LP 95 | Example : V1 1 0 SIN(0 1MV 100MEGHZ 0US 0) 96 | .LP 97 | Note VO must be zero. 98 | .RE 99 | .RE 100 | .NH 3 101 | Pulse Sources 102 | .RS 103 | .RS 104 | .LP 105 | General form : VXXXX N1 N2 PULSE(V1 V2 TD TR TF PW PER) 106 | .LP 107 | Example : V2 2 0 PULSE(0MV 1MV 0PS 2PS 2PS 10PS 50PS) 108 | .LP 109 | Note V1 must be zero. 110 | .RE 111 | .RE 112 | .NH 3 113 | Piece-wise Linear Sources 114 | .RS 115 | .RS 116 | .LP 117 | General form : VXXXX N1 N2 PWL(T0 V0 T1 V1 ....) 118 | .LP 119 | Example : V3 3 0 PWL(0PS 0MV 1PS 1MV) 120 | .LP 121 | Note T0 and V0 must be zero. 122 | .RE 123 | .RE 124 | .NH 2 125 | Independent Current Sources 126 | .NH 3 127 | Sinusoidal Sources 128 | .RS 129 | .RS 130 | .LP 131 | General form : IXXXX N1 N2 SIN(IO IA FREQ TD THETA) 132 | .LP 133 | Example : I1 1 0 SIN(0 1MA 100MEGHZ 0US 0) 134 | .LP 135 | Note IO must be zero. 136 | .RE 137 | .RE 138 | .NH 3 139 | Pulse Sources 140 | .RS 141 | .RS 142 | .LP 143 | General form : IXXXX N1 N2 PULSE(I1 I2 TD TR TF PW PER) 144 | .LP 145 | Example : I2 2 0 PULSE(0MA 1MA 0PS 2PS 2PS 10PS 50PS) 146 | .LP 147 | Note I1 must be zero. 148 | .RE 149 | .RE 150 | .NH 3 151 | Piece-wise Linear Sources 152 | .RS 153 | .RS 154 | .LP 155 | General form : IXXXX N1 N2 PWL(T0 I0 T1 I1 ....) 156 | .LP 157 | Example : I3 3 0 PWL(0PS 0MA 1PS 1MA) 158 | .LP 159 | Note T0 and I0 must be zero. 160 | .RE 161 | .RE 162 | .NH 2 163 | Josephson Junctions 164 | .RS 165 | .RS 166 | .LP 167 | General form : BXXXX N1 N2 MODNAME 168 | 169 | .LP 170 | Example : B1 2 3 JJMOD1 AREA=1.5 CONDEV=L2 171 | .LP 172 | MODNAME is the model name, 173 | CONDEV is used to simulate the modulation of critical current 174 | due to magnetic field, DEVNAME can only be inductors, voltage and 175 | current sources. 176 | .RE 177 | .RE 178 | .NH 2 179 | Transmission Line 180 | .RS 181 | .RS 182 | .LP 183 | General form : TXXXX N1 N2 N3 N4 LOSSLESS 184 | .LP 185 | Example : T1 1 0 2 0 LOSSLESS Z0=50 TD=100PS 186 | .LP 187 | N1 and N2 are nodes for port 1, and N3 and N4 are nodes for 188 | port 2. 189 | Default Z0=50ohm, TD=1sec. 190 | .RE 191 | .RE 192 | .NH 2 193 | Subcircuit Calls 194 | .RS 195 | .RS 196 | .LP 197 | General form : XYYYY SUBDEFNAME N1 N2 ..... 198 | .LP 199 | Example : X1 SGA 1 3 4 5 200 | .RE 201 | .RE 202 | .NH 203 | Subcircuit Definition 204 | .RS 205 | .RS 206 | .LP 207 | General form : .SUBCKT SUBDEFNAME N1 N2 ...... 208 | .LP 209 | General form : 210 | .LP 211 | General form : .ENDS 212 | .LP 213 | Example : .SUBCKT TEST 1 2 3 214 | .LP 215 | Example : R1 1 2 3K 216 | .LP 217 | Example : C1 2 3 3PF 218 | .LP 219 | Example : .ENDS 220 | .RE 221 | .RE 222 | .NH 223 | Model Specification 224 | .NH 2 225 | Josephson Models 226 | .RS 227 | .RS 228 | .LP 229 | General form : .MODEL MNAME JJ(,....) 230 | .LP 231 | Example : .MODEL JJMOD1 JJ(VG=2.5MV, CAP=0.6PF, ICRIT=100UA) 232 | .LP 233 | RTYPE : quasiparticle model, can be zero or one. 234 | Zero is for zero conductance, and one is for piece-wise 235 | linear conductance curve, default is 0. 236 | .LP 237 | CCT : control current type, can be zero or one. 238 | Zero is for no control current, and one is for sine x over x, 239 | default is 0. 240 | .LP 241 | VG : gap voltage, default is 2.8mV. 242 | .LP 243 | DELV : gap transition voltage, default is 0.1mV. 244 | .LP 245 | ICON : control current scale, default is 1mA. 246 | .LP 247 | R0 : subgap resistance, default is 30ohm. 248 | .LP 249 | RN : normal resistance, default is 5ohm. 250 | .LP 251 | CAP : junction capacitance, default is 2.5pf 252 | .PP 253 | ICRIT : critical current, default is 1mA. 254 | .RE 255 | .RE 256 | .NH 257 | Transient Analysis Specification 258 | .RS 259 | .RS 260 | .LP 261 | General form : .TRAN PRSTEP TSTOP 262 | .LP 263 | Example : .TRAN 1PS 100PS 20PS 0.5PS 264 | .LP 265 | PRSTEP is the printing step. 266 | .LP 267 | TSTOP is the stop time. 268 | .LP 269 | TSTART is the starting time for printing, default is 0. 270 | .LP 271 | MAXTSTEP is the maximum internal time step, default is 1ps. 272 | .RE 273 | .RE 274 | .NH 275 | Print and File Specifications 276 | .RS 277 | .RS 278 | .LP 279 | General form : .FILE FILENAME 280 | .LP 281 | General form : .PRINT PRTYPE PRNAME 282 | .LP 283 | Example : .FILE OUT1 284 | .LP 285 | Example : .PRINT NODEV 2 0 286 | .LP 287 | Example : .PRINT DEVV X1_X2_B1 288 | .LP 289 | Example : .FILE OUT2 290 | .LP 291 | Example : .PRINT DEVI B2 JJTOTAL 292 | .LP 293 | Example : .PRINT PHASE B3 294 | .LP 295 | Example : .PRINT DEVV T1 PORT1 296 | .LP 297 | Example : .PRINT DEVI T1 298 | .LP 299 | To print out device voltage or current of a subcircuit 300 | element, just expand the element name by the subcircuit call 301 | name. 302 | In the above examples, X1_X2_B1, means B1 belong to subcircuit 303 | call X2 which is in turn called by X1. 304 | This eliminates the need for a long node list in the 305 | subcircuit definition in order to print out values associated 306 | with subcircuit elements as in SPICE. 307 | .LP 308 | JJTOTAL : total current. 309 | .LP 310 | JJJOSEPH : Josephson current. 311 | .LP 312 | JJCAP : current due to capacitive effect. 313 | .LP 314 | JJRESIS : quasi-partical current. 315 | .LP 316 | JJALL : print all currents in the order specified. 317 | .LP 318 | PORT1 : print port1 of transmission line. 319 | .LP 320 | PORT2 : print port2 of transmission line, no port 321 | specification prints both ports. 322 | .RE 323 | .RE 324 | .NH 325 | Option Specifications 326 | .RS 327 | .RS 328 | .LP 329 | General form : .OPTIONS 330 | .LP 331 | Example : .OPTIONS RELTOL=0.01 MAXPHISTEP=1.5 332 | .sp 333 | .LP 334 | RELTOL=VALUE : relative tolerance, default is 0.001. 335 | .LP 336 | PHITOL=VALUE : absolute tolerance for phase, default is 337 | 0.0001, (too small, set it to 0.01). 338 | .LP 339 | VNTOL=VALUE : absolute voltage tolerance, default is 0.1 uV, 340 | only in effect when LTE option is used. 341 | .LP 342 | INTOL=VALUE : absolute current tolerance, default is 0.1 uA, 343 | only in effect when LTE option is used. 344 | .LP 345 | MAXPHISTEP=VALUE : maximum phase change allowed in one time step, 346 | default is 1.5. 347 | .LP 348 | MAXFLUXSTEP=VALUE : maximum flux change in inductor allowed in 349 | one time step. 350 | Only applies to those inductors with FCHECK flag specified. 351 | Default is 0.5e-15. 352 | .LP 353 | LTE : check for local truncation error in choosing step size, 354 | default no LTE. 355 | .LP 356 | IGWARN : ignore warning and proceed with simulation. 357 | .LP 358 | NUMDGT=VALUE : number of digits to be printed, default is 3. 359 | .RE 360 | .RE 361 | .NH 362 | Special Files 363 | .RS 364 | .RS 365 | .LP 366 | JSIM will generate some special files. 367 | All the speical files start with .jsim. 368 | They are devlist, devname, model, nodemap and subdef. 369 | .RE 370 | .RE 371 | .NH 372 | CAUTION 373 | .PP 374 | This is a preliminary version of the program. 375 | Many parameters have no defaults, and have to be specified. 376 | .NH 377 | BUGS 378 | .PP 379 | If you find any problems, please send e-mail to 380 | esfang@argon.berkeley.edu, include the input deck that causes 381 | the problem and a description of the problem. 382 | Also you may call (415) 642-0502 and contact Emerson Fang, or 383 | write to Prof. Ted Van Duzer at the above address. 384 | -------------------------------------------------------------------------------- /vendor/jsim/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coldlogix/jsim/ba1aa007dc1798cecf6ce4862f3ba6e930aa5f47/vendor/jsim/manual.pdf -------------------------------------------------------------------------------- /vendor/jsim/noise.awkf: -------------------------------------------------------------------------------- 1 | BEGIN {const=5.529e-23} 2 | $1 ~ /^[rR]/&&!/[rR][zZ]/ { 3 | print $0 4 | noise = sqrt(const*temperature/$4)*1e12 5 | printf "i%s %s %s NOISE(%fp 0.0 1.0p) \n",$1,$2,$3,noise 6 | } 7 | $1 !~/^[Rr]/||/^[Rr][Zz]/ {print $0} --------------------------------------------------------------------------------