Documentation‎ > ‎

### Output a primitive file and a MATLAB file based on a network of primitive files

#### Making New Dynamic File Models from Mason Circuits

How to output a Primitive File or a Matlab file
• Primitive file can be used for future Mason runs
• Matlab / Octave file can be used for portable calculations
• In TinyCAD, show the make_primitive argument under the Flag Block:
• make_primitive = new_primitive.xml
Step 1: Circuit Variable to Primitive Argument mapping
The variables in the model with be the arguments for the primitive file.  Note that when you create the Mason file which will generate the new primitive, the variables must have TWO underscores in front of the variable names. Variable block for the circuit which will be made into a primitive This is how the variables will look for the primitive

Step 2: Choosing components
You can only use primitive components as part of the circuit- no Touchstone components allowed.
Step 3: Circuit primitive variables
All circuit values need to be mapped to a unique variable name.  More than likely, you will need to use the calculation blocks.  Map the Ref Des of the circuit first before starting the calculation block.

The values for each component's argument is the "RefDes" + an underscore + "original argument name".  Note, that is THREE underscores, since the original argument name (such as __c) has two underscores already.  So the argument "__c" for "SEC1" is "SEC1___c".  One of the arguments for the Flat Wire Inductor whose Ref Des is "FWI2" is "__width"... so the argument is "FWI2___width".

Step 4: Defining calculations

Calculations map the Circuit's variable block / Primitives arguments to the device parameters.  The calculations are derived from the circuit's variable block.  Ultimately, the last values of the calculation block should follow the pattern described in Step 3: "RefDes" + "_" + "argument.  Note below, "SEC1___C" and "FWI___2" are defined in teh calculation block.

Step 5: Ports

Ports must be 50-ohms.
Step 6: Things to Avoid

Do not attempt to mix optimization or statistical analysis when making new primitives.

Do not make (or use) primitives that use S-Parameters in the calculations.
• Ultimately, primitives map to S-Parameters, and I have used them in hand-made primitives in the past
• Example: "S_2_1 = S_1_2"
• Example: "S_2_1_dB = "20*log10(abs(S_2_1))"
• This no longer works because of how S-parameters map from the circuit device models
• "S_2_1 = S_1_2" gets mapped to "TL1_S_2_1 = S_1_2"
• The calculation gets broken because of the way the circuit gets compiled into a single primitive
• This is an issue not just for your new primitive, but the primitives that it uses.