Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/smith/bal.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--------------------------------------------------------------------------------
module Main where

import Smith
import Complex
--------------------------------------------------------------------------------
--- EE command stuff 
normalize :: Complex Double -> [Complex Double] -> [Complex Double]
normalize res (x:xs) = map ((1/res) *) (x:xs)

inductive_Reactance :: Double -> Double -> Double
inductive_Reactance ind freq = omega freq * ind

capacitive_Reactance :: Double -> Double -> Double
capacitive_Reactance cap freq = (-1) / omega freq * cap

omega :: Double -> Double
omega freq = 2.0 * pi * freq
--------------------------------------------------------------------------------

micro = 1.0/1000000.0
kilo = 1000.0

xL freq = inductive_Reactance (2.0 * micro) (freq * kilo)
xReactance = map xL [100,500..3000] -- 0.1Ghz to 3.0Ghz in 0.4Ghz step
xDist = map (5.0 :+) xReactance
impedance = normalize 50 xDist

main = do pInit
          showSmithChart
          putStrLn $ pColor "green"  
          plotSmith (2:+0.4)
          putStrLn $ pColor "red"
          mapM_ plotSmith impedance
          lineSmith impedance        
          putStrLn pClose 
          
          
          
          

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].