Reverse stepsize and finaltime in optran command,

stepsize first as in tran command.
This commit is contained in:
Holger Vogt 2020-06-16 15:05:39 +02:00
parent 33d7cbad98
commit a077bac97d
3 changed files with 24 additions and 15 deletions

View File

@ -37,13 +37,12 @@ Step 3 may be skipped by
option srcsteps=0 option srcsteps=0
command optran n3 overrides srcsteps command optran n3 overrides srcsteps
n4 sets the time for transient simulation. n4 sets the step size for transient simulation towards the operating point.
n5 sets the step size for transient simulation. n5 sets the time for transient simulation towards the operating point.
n6 set a ramp time to ramp all indpendent voltage or n6 set a ramp time to ramp all independent voltage or
current sources until 100% is reached at opramptime. current sources until 100% is reached at opramptime.
(not yet implemented)
The transient op calculation uses the 'UIC' flag for its startup. The transient op calculation uses the 'UIC' flag for its startup.
Basically two applications come to mind: You may use this with Basically two applications come to mind: You may use this with
@ -53,4 +52,9 @@ simulation when all nodes have become stable, might be desirable,
but has not yet been implemented. but has not yet been implemented.
One also may use the optran for a first transient simulation, maybe One also may use the optran for a first transient simulation, maybe
with different step sizes, before the next (tran, ac, pz, noise) with different step sizes, before the next (tran, ac, pz, noise)
simulation is commencing. simulation is commencing. So you may reach a certain bias point
quickly and with coarse time steps, and then continue with fine
steps to see details. For example a power amp in electro-thermal
simulation may run for some seconds (minutes?) until the final
temperature is reached, and then the detailed transient or
an ac simulation starts.

View File

@ -11,8 +11,8 @@ else
*** script for standard ngspice *** script for standard ngspice
* Start optran without first iteration, * Start optran without first iteration,
* without gmin stepping and without src stepping * without gmin stepping and without src stepping
* optran duration 4s, step size 10 ms * optran step size 10 ms, duration 40s,
optran 1 0 0 4 1e-2 0 optran 1 0 0 1e-2 4 0
tran 1u 10m tran 1u 10m
echo echo
* output power * output power
@ -47,7 +47,8 @@ tran 1u 100m
fft out fft out
set xbrushwidth=4 set xbrushwidth=4
set color0=white set color0=white
plot mag(out) xlimit 0 10k
* to see the harmonics
plot mag(out) xlimit 0 10k ylimit 0 30m plot mag(out) xlimit 0 10k ylimit 0 30m
end end
.endc .endc

View File

@ -50,11 +50,15 @@ static double opramptime = 0.;
CKTnoOpIter (default 0, set by 'option noopiter') CKTnoOpIter (default 0, set by 'option noopiter')
CKTnumGminSteps CKTnumGminSteps
CKTnumSrcSteps CKTnumSrcSteps
opfinaltime
opstepsize opstepsize
opfinaltime
opramptime opramptime
*/
A typical command may be
optran 1 0 0 50u 10m 0
(no initial iteration, no gmin stepping, no source stepping,
stepsize for optran 50 us, optran run until 10 ms, no supply ramping
*/
void com_optran(wordlist* wl) { void com_optran(wordlist* wl) {
wordlist* wltmp = wl; wordlist* wltmp = wl;
char* stpstr; char* stpstr;
@ -76,11 +80,11 @@ void com_optran(wordlist* wl) {
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;
opfinaltime = strtod(wltmp->wl_word, &stpstr); opstepsize = strtod(wltmp->wl_word, &stpstr);
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;
opstepsize = strtod(wltmp->wl_word, &stpstr); opfinaltime = strtod(wltmp->wl_word, &stpstr);
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;