Example 1: Physics Computational Script

Overview

This example explores using Artemis to document physics calculations which determine different properties of a circuit

Code

# Make sure to pip install scikit-rf before running!

import numpy as np
from time import sleep
import matplotlib.pyplot as plt
import skrf as rf

# @card title="Background" side-color=rgb(0,255,0)
''' @blockdoc
## Modeling Transmission Line Properties
### Background
Assume we have the circuit below, excited by some source with a voltage $$V$$ and a source impedance $$Z_s = z\Omega$$:
![Circuit](https://i.imgur.com/QzbfikU.jpg)
'''
# @stop

# @card title="Assumptions" side-color=rgb(0,255,0)
''' @blockdoc
## Assumptions
Let's assume the following constants for the circuit:
| Constant | Value |
| :---: | :---: |
| $$Z_0$$ | 75 Ohm |
| $$Z_L$$ | 150 Ohm |
| $$d$$ | 12 m |
| $$f$$ | 250 MHz |

We will implement these properties into code with the following code:
# @linkedcode start="circuit_properties_start" end="circuit_properties_end"
'''
# @stop

# @marker circuit_properties_start
# Setup circuit properties
freq = rf.Frequency(250, npoints=1, unit='MHz')
Z_0 = 75  # Ohm
Z_L = 150  # Ohm
d = 12  # m
VF = 0.67
att = 0.02 # Np/m. Equivalent to 0.1737 dB/m
# @marker circuit_properties_end

# @card title="Circuit Setup" side-color=rgb(0,255,0)
''' @blockdoc
## Calculating the input impedance
Now, let's calculate calculate the propogation constant $$\gamma = \alpha + j\beta$$ and the input impedance $$Z_{in}$$:
# @linkedcode start="input_impedance_start" end="input_impedance_end"
'''
# @stop

# @marker input_impedance_start
alpha = att  # Np/m !
beta = freq.w/rf.c/VF
gamma = alpha + 1j*beta
Z_in = rf.zl_2_zin(Z_0, Z_L, gamma * d)
# @marker input_impedance_end

# @card title="Circuit Setup" side-color=rgb(0,255,0)
# @doc ## Circuit Setup
# @doc Now, let's explore calculating the transmission line properties of this circuit.
# @doc We'll fix our source impedance to be $$100 \Omega$$ by writing `Z_s = 100`
Z_s = 100
V_s = 0
# @doc Next, let's fix a value for $$V_s$$, the voltage for the source in Volts
# @input number data=V_s

# @card title="Circuit Calculation" side-color=rgb(0,0,255)
# @doc ## Voltage Input For Transmission Line
# @doc At the input of the transmission line, the voltage is a voltage divider circuit:
# @doc $$V_{in} = V_s \frac{Z_{in}}{Z_s + Z_{in}}$$
V_in = V_s * (Z_s / (Z_s + Z_s))
# @doc Using this formula, we can see the voltage at the input of the transmission line is $$\framebox{<<str(V_in)>> V}$$
# @stop 

# @card title="Circuit Calculation" side-color=rgb(0,0,255)
# @doc ## Current Input For Transmission Line
# @doc At the input of the transmission line, the current is: $$I_{in} = \frac{V_s}{Z_s + Z_{in}}$$
I_in = (V_s / (Z_s + Z_s))
# @doc Using this formula, we can see the current at the input of the transmission line is $$\framebox{<<str(I_in)>> A}$$
# @stop 

# @card title="Circuit Calculation" side-color=rgb(0,0,255)
# @doc ## Power Input For Transmission Line
# @doc Now, we will use the input voltage and current to solve for the power $$P_{in} = \frac{1}{2}R[V_{in}I_{in}^*]$$
P_in = 1/2 * np.real(V_in * np.conj(I_in))
# @doc Using this formula, we can see the power at the input of the transmission line is $$\framebox{<<str(P_in)>> W}$$
# @stop 

# @card title="Wrapup" side-color=rgb(255,0,0)
''' @blockdoc
## Wrapup
Hopefully you've learned how to model some of the elementary properties of a transmission line.
If you'd like to learn more, read the [Scikit-Rf Documentation](https://scikit-rf.readthedocs.io/en/latest/examples/networktheory/Transmission%20Line%20Properties%20and%20Manipulations.html)
'''

Result


Did this page help you?