如何使用 UliEngineering 在 Python 中根据功率和电阻计算电阻电流

你可以使用 UliEngineering Python 库,在已知功耗和电阻值的情况下轻松计算流过电阻的电流:

resistor_current_by_power.py
from UliEngineering.Electronics.Resistors import *
from UliEngineering.EngineerIO import *

# 计算 1kΩ 电阻上消耗 1W 功率时的电流
current = resistor_current_by_power("1W", "1k")
print(f"Current for 1W in 1kΩ: {format_value(current, 'A')}")

# 计算 100Ω 电阻上消耗 0.5W 功率时的电流
current = resistor_current_by_power("0.5W", "100Ω")
print(f"Current for 0.5W in 100Ω: {format_value(current, 'A')}")

示例输出

resistor_current_by_power_output.txt
Current for 1W in 1kΩ: 31.6 mA
Current for 0.5W in 100Ω: 70.7 mA

电流使用以下公式计算:$I = \sqrt{\frac{P}{R}}$

相关文章


Check out similar posts by category: Electronics, Python