Python Forum
Parameters aren't seen inside function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parameters aren't seen inside function
#1
Hello,

The question is related to the use of the Lcapy library (circuit analysis).
The 1st version of the Vin declaration (which is commented out) does not work: freq and pi are not visible in the Circuit function.

from lcapy import Circuit
import numpy as np
from matplotlib.pyplot import subplots, savefig
from math import pi
freq = 130e6
cct = Circuit('''
##... Vin 1 0 {1*sin(2*pi*freq*t)}
... Vin 1 0 {sin(130e6*2*3.14159*t)}
... Rin 1 2 50
... Cs  2 4 1e-12
... L   2 3 0.32e-6
... Rs  3 4 5
... Cl  4 0 3e-12''')

t = np.linspace(0, 2e-7, 1000)
vcl = cct.Cl.v.evaluate(t)

fig, ax = subplots(1)
ax.plot(t, vcl, linewidth=2)
ax.set_xlabel('Time (s)')
ax.set_ylabel('Output voltage (V)')
ax.grid(True)

savefig('antenna_output.png')
How to make them visible inside function?

Thanks.

Sancho.
Reply


Messages In This Thread
Parameters aren't seen inside function - by Sancho_Pansa - Oct-26-2020, 10:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 349 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  with open context inside of a recursive function billykid999 1 580 May-23-2023, 02:37 AM
Last Post: deanhystad
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 796 May-02-2023, 08:40 AM
Last Post: Gribouillis
Question How to compare two parameters in a function that has *args? Milan 4 1,270 Mar-26-2023, 07:43 PM
Last Post: Milan
  function accepts infinite parameters and returns a graph with those values edencthompson 0 865 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  How can I write a function with three parameters? MehmetAliKarabulut 1 2,430 Mar-04-2021, 10:47 PM
Last Post: Larz60+
  How to make global list inside function CHANKC 6 3,106 Nov-26-2020, 08:05 AM
Last Post: CHANKC
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,150 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  Function parameters and values as string infobound 1 1,764 Jul-24-2020, 04:28 AM
Last Post: scidam
  Creating function inside classes using type wolfmansbrother 3 2,341 Mar-20-2020, 01:21 AM
Last Post: wolfmansbrother

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020