Home › Forums › Bug Reports › yvalue() and xvalue() don’t work in subcircuits
- This topic has 6 replies, 2 voices, and was last updated 1 year ago by username.
-
AuthorPosts
-
7. September 2023 at 23:02 #7705
Hi,
I am trying to build a lumped element circuit representing an inductor. I defined a Dataset Equation which holds the vectors for the element values of the circuit. With the external given value L_ext from the top schematic the nearest possible values should be extracted from the Dateset vectors and filled in as values.
I get the right values if I test it in the subcircuit itself, but when I am trying to use it in the top schematic a get the following errors:Error in ‘L1.getValues’: Different variable sizes in equation “xvalue(L_nominal, L_ext)”.
Error in ‘L1.getValues’: Different variable sizes in equation “yvalue(L, idx)”.
Error in ‘L1.getValues’: Different variable sizes in equation “xvalue(L_nominal, L_ext)”.
Error in ‘L1.getValues’: Different variable sizes in equation “yvalue(C, idx)”.
Error in ‘L1.getValues’: Different variable sizes in equation “xvalue(L_nominal, L_ext)”.
Error in ‘L1.getValues’: Different variable sizes in equation “yvalue(R1, idx)”.
Error in ‘L1.getValues’: Different variable sizes in equation “xvalue(L_nominal, L_ext)”.
Error in ‘L1.getValues’: Different variable sizes in equation “yvalue(R2, idx)”.I the subcircuit it self it seems to work just fine:
I also tried to only use yvalue to find the nearest index and then just use the index to get access the vector but that doesn’t work at all. I always the the first vector value back. vector[idx] = 12, but if I manually enter vector[21] (21 is the value of idx) I get the write answer of 33.
Is there any way to make this happen?
Greetings Chris- This topic was modified 5 months ago by maelh.
7. September 2023 at 23:05 #7706I have zipped the attachments. *.sch seems not to be allowed.
Attachments:
21. September 2023 at 20:36 #7721I also want to do something like that for the coilcraft aircore inductor series. What inductances are you trying to describe?
It should be relatively easy with a c++ or a verilogA model. There are templates in QS and examples on the website.
I also want to interpolate the descriptive values. That way the model could be more useful in a optimization task.
21. September 2023 at 21:11 #7725Hi Carsten,
I want to model the Coilcraft 1206CS series in this example and later the AxxT/BxxT with the Transmission Line model.
In AWR MWO and similar tools I also always use interp1() to linearly interpolate the model. This is useful, as you said, for certain types of optimization algorithms. Since the only two functions in the built-in help that might help at least a little are the nearest neighbor functions aka x/yvalue(), I settled for that.
The C++ models are reasonably okay, but the built-in template does not even compile due to typecast errors. Nevertheless, I managed to implement an SPDT and an SPST switch that can also respond to a specific bit. Like the AWR MWO SPDT switch.
But with the coilcraft models you would run into other problems. It is not possible to use an array as parameter input for the model. At least if you look at the get functions from “qucsstudio_library.h”. There is only getNumber(), no array or list etc. This would mean that you would have to hardcode the array in the C code. That’s a shame, because Coilcraft only uses two types of models, the one from my first post and the transmissionline one. So the reusability would not be very good.
The second problem is that you would also have to write your own interp1() and findNearestNeighbor() function for it. Mayby some thing like https://stackoverflow.com/questions/9394867/c-implementation-of-matlab-interp1-function-linear-interpolationSo all in all not great. Would be much happier if the xvalue() and yvalue() function worked as intended.
21. September 2023 at 22:23 #7726I created a small example. (see attached .qucs)
It contains only a resistor adjustable by a parameter. However, you should be able to extend it.
It is – however – tedious to initialize the array. Maybe its better to switch to C++. The verilog-A-Compiler creates a c++ file, that could be used as a starting point.
Cheers
CarstenEdit: I only read you post now. Seems you figured out already all the obstacles 🙂
- This reply was modified 1 year ago by Carsten.
Attachments:
21. September 2023 at 22:33 #7729The c++ code could read the arrays from a textfile, as done for touchstone.
@Michael: Is it possible to share the c++ code of the touchstone-file-component? I suppose its also written in the same c++ environment?
22. September 2023 at 20:29 #7730The function to read in a text file is a great idea!
I simply selected the entire table in the PDF file provided by Coilcraft with the cursor and transferred it to an empty Notepad++ only using ctrl+c/v. Then I used the “Find and Replace” function to replace spaces with ‘,’ and saved the whole thing as a .csv.
From there, I used Matlab/Octave to create the schematic equation you can see in the first post. Because I’m lazy and didn’t want to manually type out the table from Coilcraft, plus it would be very error prone.
So what I’m saying is that I already have a readable text file with the arrays, which is super easy to create with Notepad++ and requires no programming skills. So this should be easy for everyone else. So a .csv passing function for array parameters in “qucsstudio_library.h” would be a useful addition for C++ models. -
AuthorPosts
- You must be logged in to reply to this topic.