Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Sensitivity for PWL source

30 views
Skip to first unread message

zhengqi gao

unread,
Jul 30, 2024, 6:28:42 PM7/30/24
to xyce-users
Hi, 

I am trying the transient sensitivity of PWL source using Xyce. My netlist is attached. It is a simple RC ladder with only 4 elements, and I think the derivatives should be non-zero for Vin:v1, Vin:v2, and Vin:v3. But I found the output sensitivity are all zeros. 

Moreover, another bug I found is if I add 'Vin:v3' in the SENS command, Xyce will directly raise an error, which complains that the variable v3 is not defined. I am confused  --- up until v2 is all fine, why adding Vin:v3 makes Xyce break down?

Additionally, when I use `adjoint=1`, it seems to have a lot of warnings about transient parameters not found and all sensitivities are zeroes, even for R1:R and C1:C.

Thanks! 
circuit2.txt

Thomas Russo

unread,
Jul 30, 2024, 7:28:07 PM7/30/24
to xyce-users
I can't answer the question of how you can obtain sensitivities of your circuit to the three voltage values of your PWL, but I can explain why you're getting the results you are getting.

The V1 and V2 of the voltage source are strictly parameters for the PULSE and EXP source types, and have nothing to do with the PWL source.   That's why you're getting zero for those dependencies, they aren't ever used in your circuit.   There is no V3 parameter to the voltage source device, which is why you are getting an error about an undefined parameter when you try to use it.

Unfortunately, the various point values of the PWL source are not given names that are accessible as parameters of the voltage source device for use in sensitivity, and I don't know how one might use them as parameters for a sensitivity analysis.  Those points are stored in a vector and each one doesn't have a unique name.  Hopefully, Eric can give you a workaround to get what you need. 

Thomas Russo

unread,
Jul 30, 2024, 7:31:32 PM7/30/24
to xyce-users
And by this, I mean that V:v1 and V:v2 really mean "the parameter known to the VSRC device internally as V1 and V2" not "the parameters you've defined as v1 and v2 in .param statements."

V0, V1, and V2 actually do have meaning to the VSRC device, but they have nothing to do with what you've called your parameters in .param statements.  V0  is the offset voltage for the SIN and SFFM modes of the VSRC, and V1/V2 are parameters defining the behavior of PULSE and EXP modes.  

zhengqi gao

unread,
Jul 30, 2024, 7:33:46 PM7/30/24
to xyce-users
Hi, 

Thanks so much for your reply! That really helps a lot.

I thought the parameter names in PWL are defined as  PWL(t1 v1 t2 v2 t3 v3 t4 v4 ....), so I can call .SENS with Vin:v1, Vin:v2, Vin:v3, Vin:v4. 

Would it be possible to add transient sensitivity support to PWL parameters in the near term? 

-Zhengqi

Tom Russo

unread,
Jul 30, 2024, 7:43:10 PM7/30/24
to zhengqi gao, xyce-users
The parameters in the .sens line are the parameters of the device as defined in their parameter lists internally, which in MOST cases is what the manual says for their names.  But for PWL the names in the manual do NOT correspond to what the code actually knows them as --- in fact, there is no name for the various elements of the PWL argument list, because that list has indeterminate size.

If you run "Xyce -param" and save the output, you can see what the actual names of parameters in all devices are,  and if you look for "v level 1" in that output, you'll see that there are no parameters that correspond to PWL parameters.  As far as I know, only instance and model parameters can be used in sensitivity, but perhaps I'm mistaken and one can use global params for that purpose.  Eric will correct me if I'm wrong --- I am only basing my assumption on the fact that none of the test suite netlists for sensitivity use global params in the params list, only model and instance parameters of devices.

--
You received this message because you are subscribed to the Google Groups "xyce-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xyce-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xyce-users/e0ae4690-8384-4ea5-acc5-033b6072008bn%40googlegroups.com.


--
Tom Russo    KM5VY 
Tijeras, NM 

 echo "prpv_a'rfg_cnf_har_cvcr" | sed -e 's/_/ /g' | tr [a-m][n-z] [n-z][a-m]

xyce-users

unread,
Jul 30, 2024, 8:16:29 PM7/30/24
to xyce-users

Hello Zhengqi,

Nice to hear from you.

So, in general,   .param and .global_param can be used as sensitivity parameters.  So, although the  un-named PWL parameters are not supported directly for sensitivity analysis, it is theoretically possible to set the PWL values using a .params, and then refer to those .params on the .SENS line.

However, there is another problem, which is related to the independent Vsrc source.   The Vsrc has a very limited analytical sensitivity support at the moment, so it produces the wrong answer.  (It unconditionally assumes a DC source).  Also, it isn't properly set up to do numerical sensitivities either.  So, it just doesn't work for your problem at the moment, even using .params to set the PWL values.  There are at least two bugs that were revealed by this exercise that need fixing.

Fortunately, there is a partial work around, using the TABLE feature of the B-source, which is functionally equivalent to the VPWL source.   The code for the Bsrc is completely separate from the Vsrc, so it doesn't have as many limitations.  But it isn't perfect either.  In short, direct sensitivities work using the Bsrc, but adjoints don't.

I was able to put together a simple circuit for which .param-specified PWL values in a Bsrc works with sensitivity analysis .  However, like I said, it currently only works for direct sensitivities, not adjoints.    I haven't had time to debug why it is broken for adjoints yet.

Here is my simple B-PWL direct sensitivity example.  I just ran this in my local copy of Xyce and it worked, producing nonzero answer.  I have NOT yet checked if these nonzero answers are correct.

-------
Behavioral source - piece wise linear signal, transient direct sensitivity example.
* adjoint sensitivities currently don't work for this example.

.param v1=0, v2=3, v3=2, v4=2, v5=5, v6=5, v7=-2, v8=1, v9=-1, v10=4, v11=3

bpwl1 1 0 v = {table(time,0,{v1},2,{v2},3,{v3},4,{v4},4.01,{v5},4.5,{v6},4.51,{v7},7,{v8},9,{v9},9.01,{v10},10,{v11})}
r1 1 2 500
r2 2 0 250

.sens objfunc={v(2)} param=v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11

.options sensitivity direct=1 adjoint=0
*.print tranadjoint
.print sens

.tran 0.01s 30s
.print tran v(1)
.end
-------

I'll have to do some debugging to figure out why the above example doesn't work for adjoints (currently for adjoints it returns all zeros).  It is *probably* an easy fix. 

Also, some of the issues uncovered for the VPWL source need to be fixed as well.  At the very least, it should be fixed to work with numerical sensitivities.

thanks,
Eric

xyce-users

unread,
Jul 30, 2024, 8:25:58 PM7/30/24
to xyce-users
I'll also mention that there is a few regression tests which uses .params for the sensitivity parameters.

One of them is the sensCapGear_global.cir, which can be found in the Xyce_Regression/Netlists/SENS directory.

That test uses transient direct sensitivities, not adjoints,  however.  Probably for the reasons identified in this discussion.

thanks,
Eric

Tom Russo

unread,
Jul 30, 2024, 8:50:48 PM7/30/24
to xyce-users
Heh.  Yeah, I see that now.  I had done a "grep -r '^\.sens' *" on the Netlists directory and come up with no netlists that used params that way, so concluded that it might not work.  That's because the ones that *do* use global params have ".SENS" not ".sens" and I didn't do a case-insensitive search.   Mea culpa, mea culpa, mea maxima culpa.


xyce-users

unread,
Jul 30, 2024, 9:28:09 PM7/30/24
to xyce-users
No problem; there are some real problems that need fixing.  Just that particular detail has been implemented in Xyce.  It just doesn't work for VPWL sources yet, for reasons I haven't yet tracked down.

Interestingly, looking over the code, in 2023 I fixed a bug that had to do with applying .STEP to Vsrc PWL parameters, and the method for doing that was with .params.  The tests for *that* work are in the test directory Xyce_Regression/Netlists/Certification_Tests/ISSUE_565_566.

So, most of the machinery is there to support sensitivities using .param with VPWL devices, based on that work.  But there is something missing in the code, preventing it from working, that I need to track down.

Eric
Reply all
Reply to author
Forward
0 new messages