def _stamp_vcvs(n, vcvs, context):
"""
Stamp a VCVS in the MNA matrix by adding KVL and KCL equations to the
kvl_equations and kcl_equations lists in the context dictionary.
"""
node_voltages = context["node_voltages"]
kvl_equations = context["kvl_equations"]
kcl_equations = context["kcl_equations"]
vcvs_currents = context["vcvs_currents"]
node1, node2, node3, node4 = vcvs["nodes"]
v1 = node_voltages[node1]
v2 = node_voltages[node2]
v3 = node_voltages[node3]
v4 = node_voltages[node4]
gain = vcvs.get("gain", sympy.Symbol("A"))
kvl_equation = sympy.Eq(gain * (v2 - v1), v4 - v3)
kvl_equations.append(kvl_equation)
current = vcvs_currents[n]
kcl_equations[node3] += -current
kcl_equations[node4] += current
评论列表
文章目录