PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 24, 2022

[FIXED] How to plot function embedded in module in Mathematica

 August 24, 2022     module, visualization, wolfram-mathematica     No comments   

Issue

I want to plot a 2D graph for this function. Efficiency of a SS topology resonant circuit I am new to Mathematica. This is what I have tried, I would appreciate it if someone could help me troubleshoot it and post a working version.

Eff [d_,f_]:=Module[{C1,C2,L1,L2,R1,R2,Rs,Ro,a,b,w,mu,RL,M,eff,fr,Vi,N1,N2},
w = 2 Pi f;
C1 = 1/(L1*w^2);
C2= 1/(L2*w^2);
L1 = L2 = 14 10^-6;fr=270 10^3;
Ro=R1=R2=Rs=0.2;
a = b = 0.5; mu = 4 Pi*10^-7; Vi = 100;N1=N2=100;
M[d]=  N1 N2 Block[{k = Sqrt[(4 a b)/((a + b)^2 + d^2)]}, mu Sqrt[a b]  2/k ((1 - k^2/2) EllipticK[k^2] - EllipticE[k^2])];
eff =(C2^2*M[d]^2*Ro*w^4)/(R1 + Rs + C2*(-2*L2 + C2*(R2 + RL)^2)*(R1 + Rs)*w^2 + C22*(M [d]2*(R2 + RL) + L2^2*(R1 + Rs))*w^4)
]
Plot[Eff [0.1,f] ,{f,100 10^3,100 10^6}]

The values are test values. Please I will appreciate any help to make this work.


Solution

Well, here is a version showing that Mathematica code does not need to look awful. :)

Eff[d_, f_] := Module[
  {
   L1 = 14 10^(-6),
   L2 = 14 10^(-6),
   R1 = 0.2,
   R2 = 0.2,
   Rs = 0.2,
   Ro = 0.2,
   a = 0.5,
   b = 0.5,
   w = 2 Pi f,
   mu = 4 Pi 10^(-7),
   RL = 1,
   N1 = 100,
   N2 = 100,
   C1, C2, M, k
  },
  C1 = 1 / (L1*w^2);
  C2 = 1 / (L2*w^2);
  k = Sqrt[
    (4 a b)/
     ((a + b)^2 + d^2)
    ];
  M = N1 N2 mu Sqrt[a b] 2 / k 
    ((1 - k^2 / 2) EllipticK[k^2] - EllipticE[k^2]);
  Return[
   (C2^2 M^2 Ro w^4) /
    (
     R1 + Rs
      + C2 (-2 L2 + C2 (R2 + RL)^2) (R1 + Rs) w^2
      + C2^2 (M^2 (R2 + RL) + L2^2 (R1 + Rs)) w^4 
     )
   ]
  ]

and

LogLinearPlot[
 Evaluate[
  Table[
   Eff[d, f], {d, 0.1, 1.1, 0.1}
   ]
  ], {f, 10^3, 10^8},
 Frame -> True,
 GridLines -> Automatic,
 PlotLegends -> Table[d, {d, 0.1, 1.1, 0.1}]
 ]

or

Plot3D[
 Eff[d, f], {d, 0.1, 1.1}, {f, 10^3, 10^8},
 ScalingFunctions -> {Identity, "Log", Identity},
 PlotRange -> All
 ]


Answered By - mikuszefski
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing