-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation: electricity (circuits) (#959)
* Fix documentation * Fix issues * Fix issue
- Loading branch information
Showing
31 changed files
with
1,604 additions
and
835 deletions.
There are no files selected for viewing
56 changes: 34 additions & 22 deletions
56
...ectricity/circuits/couplers/attenuation_coefficient_of_three_link_microwave_attenuator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 72 additions & 35 deletions
107
...lyphysics/laws/electricity/circuits/couplers/conductivity_for_rectangular_loop_coupler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 46 additions & 21 deletions
67
symplyphysics/laws/electricity/circuits/couplers/full_gain_of_transistor_amplifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,61 @@ | ||
""" | ||
Total gain of transistor amplifier | ||
================================== | ||
The total gain of a transistor amplifier depends on the gain of the input and output | ||
matching circuits and the transistor gain. | ||
.. | ||
TODO: find link | ||
""" | ||
|
||
from sympy import Eq, solve | ||
from symplyphysics import (Symbol, validate_input, validate_output, dimensionless, convert_to_float) | ||
from symplyphysics import ( | ||
validate_input, | ||
validate_output, | ||
convert_to_float, | ||
symbols, | ||
clone_as_symbol, | ||
) | ||
|
||
total_gain = clone_as_symbol(symbols.circuit_gain) | ||
""" | ||
Total gain of the transistor amplifier. See :symbols:`circuit_gain`. | ||
""" | ||
|
||
# Description | ||
## When calculating the total gain of a transistor amplifier, it is also worth taking into account | ||
## the gain coefficients of the input and output matching circuits. | ||
input_circuit_gain = clone_as_symbol(symbols.circuit_gain, display_symbol="gain_i", display_latex="\\text{gain}_\\text{i}") | ||
""" | ||
Input matching :symbols:`circuit_gain`. | ||
""" | ||
|
||
## Law is: G = G1 * G2 * G3, where | ||
## G - full gain of the transistor amplifier, | ||
## G1 - gain of the input matching circuit, | ||
## G2 - transistor gain, | ||
## G3 - gain of the output matching circuit. | ||
transistor_gain = clone_as_symbol(symbols.circuit_gain, display_symbol="gain_t", display_latex="\\text{gain}_\\text{t}") | ||
""" | ||
Transistor gain. See :symbols:`circuit_gain`. | ||
""" | ||
|
||
full_gain = Symbol("full_gain", dimensionless) | ||
output_circuit_gain = clone_as_symbol(symbols.circuit_gain, display_symbol="gain_o", display_latex="\\text{gain}_\\text{o}") | ||
""" | ||
Output matching :symbols:`circuit_gain`. | ||
""" | ||
|
||
gain_of_input_matching_circuit = Symbol("gain_of_input_matching_circuit", dimensionless) | ||
transistor_gain = Symbol("transistor_gain", dimensionless) | ||
gain_of_output_matching_circuit = Symbol("gain_of_output_matching_circuit", dimensionless) | ||
law = Eq(total_gain, input_circuit_gain * transistor_gain * output_circuit_gain) | ||
""" | ||
:laws:symbol:: | ||
law = Eq(full_gain, | ||
gain_of_input_matching_circuit * transistor_gain * gain_of_output_matching_circuit) | ||
:laws:latex:: | ||
""" | ||
|
||
|
||
@validate_input(gain_of_input_matching_circuit_=gain_of_input_matching_circuit, | ||
@validate_input(gain_of_input_matching_circuit_=input_circuit_gain, | ||
transistor_gain_=transistor_gain, | ||
gain_of_output_matching_circuit_=gain_of_output_matching_circuit) | ||
@validate_output(full_gain) | ||
gain_of_output_matching_circuit_=output_circuit_gain) | ||
@validate_output(total_gain) | ||
def calculate_full_gain(gain_of_input_matching_circuit_: float, transistor_gain_: float, | ||
gain_of_output_matching_circuit_: float) -> float: | ||
result_expr = solve(law, full_gain, dict=True)[0][full_gain] | ||
result_expr = solve(law, total_gain, dict=True)[0][total_gain] | ||
result_expr = result_expr.subs({ | ||
gain_of_input_matching_circuit: gain_of_input_matching_circuit_, | ||
input_circuit_gain: gain_of_input_matching_circuit_, | ||
transistor_gain: transistor_gain_, | ||
gain_of_output_matching_circuit: gain_of_output_matching_circuit_, | ||
output_circuit_gain: gain_of_output_matching_circuit_, | ||
}) | ||
return convert_to_float(result_expr) |
Oops, something went wrong.