Documentation‎ > ‎

Write a Mason File with Variables


This page picks up from the minimal Mason file example.

Variables

Variables are useful when multiple devices need to be controlled at the same time, or when a calculation needs to be performed.  You can look over the many example circuits provided when Mason is downloaded.

     <?xml version="1.0"?>                                                               
     <mason>                                                                             
        <freq start="100 MHz" stop="200 MHz" step="5 MHz" />                             
        <output name="sample.out" />                                                     
        <variables>                                                                      
           <z0 value="70.71" />                                                          
           <f_mid value="150 MHz" />                                                     
        </variables>                                                                     
        <model alias="TL">                                                               
           <primitive name="simple_transmission_lines/lossless_transmission_line.xml" /> 
        </model>                                                                         
        <port number="1" node="1" impedance="50" />                                      
        <port number="2" node="2" impedance="100" />                                     

        <TL node_list="1 2" >                                                            
           <z0 value="z0" /> the variable name is independent of the primitive argument  
           <f0 value="f_mid" />                                                          
           <theta value="90 deg" />                                                      
        </TL>                                                                            
        <flag output_data_format="dB" set_width="15" />                                  
     </mason>                                                                            


Calculations
The fundamental difference between a calculation and a variable tag is that calculations can be algebraic expressions but cannot be optimized, and the variable's value can be optimized.  One can optimize a variable which feeds into a calculation. of course.  Another difference is there is one variable block, but can be lots of calculation tags.

     <?xml version="1.0"?>                                                               
     <mason>                                                                             
        <freq start="100 MHz" stop="200 MHz" step="5 MHz" />                             
        <output name="sample.out" />                                                     
        <variables>                                                                      
           <f_mid value="150 MHz" />                                                     
        </variables>                                                                     
        <calculation equation="z0=sqrt(100*50)" />                                       
        <model alias="TL">                                                               
           <primitive name="simple_transmission_lines/lossless_transmission_line.xml" /> 
        </model>                                                                         
        <port number="1" node="1" impedance="50" />                                      
        <port number="2" node="2" impedance="100" />                                     

        <TL node_list="1 2" >                                                            
           <z0 value="z0" /> the variable name is independent of the primitive argument  
           <f0 value="f_mid" />                                                          
           <theta value="90 deg" />                                                      
        </TL>                                                                            
        <flag output_data_format="dB" set_width="15" />                                  
     </mason>                                                                          

Comments