Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Manipulate a complex expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77836] Re: [mg77807] Re: Manipulate a complex expression
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Mon, 18 Jun 2007 06:52:45 -0400 (EDT)
  • References: <f505ip$qug$1@smc.vnet.net> <14464692.1182091779273.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

Manipulate needs to "see" the dependency on f and VolumeFraction, but  
otherwise, Set is faster than SetDelayed, and most of the functions don't  
have to be functions:

(* formulas *)
Clear["Global`*"]
omega = 2*Pi*f;
EpsilonCyt = PermittivityCyt - (ConductivityCyt/omega)*I;
EpsilonMembrane =
   PermittivityMembrane - (ConductivityMembrane/omega)*I;
EpsilonMedium = PermittivityMedium - (ConductivityMedium/omega)*I;
CMFCell = (EpsilonCyt - EpsilonMembrane)/(EpsilonCyt +
      2*EpsilonMembrane);
EpsilonCell = EpsilonMembrane*((v^3 + 2*CMFCell)/(v^3 - CMFCell));
MeasuredCMF[vfrac_][f_] =
   Simplify[vfrac*((EpsilonCell - EpsilonMedium)/(EpsilonCell +
         2*EpsilonMedium))];
v = CellRadius/(CellRadius - MembraneThickness);

(* constants (sort of) *)
Epsilon0 = 8.85/10^12;
PermittivityCyt = 120*Epsilon0;
PermittivityMembrane = 6*Epsilon0;
PermittivityMedium = 80*Epsilon0;
ConductivityCyt = 0.15;
ConductivityMedium = 0.15;
ConductivityMembrane = 1/10^9;
CellRadius = 10/10^6;
MembraneThickness = 9/10^9;

LogLinearPlot[Evaluate[Re[MeasuredCMF[0.1][f]]], {f, 1*10^5, 1*10^9}]

Manipulate[
  LogLinearPlot[
   Evaluate[Re[MeasuredCMF[VolumeFraction][f]]], {f, 1*10^5,
    1*10^9}], {{VolumeFraction, 0.2}, 0.1, 0.5}]

The chart changes only in its scale, since

MeasuredCMF[vfrac][f] // Simplify

((-0.0000608595 - (0.+ 4.64758*10^-12 \[ImaginaryI]) f -
    2.14458*10^-18 f^2) vfrac)/(0.00012172+ (0.+
     4.60111*10^-10 \[ImaginaryI]) f - 1.57672*10^-17 f^2)

is vfrac * (a function of the other variables and constants).

Bobby

On Sun, 17 Jun 2007 05:06:25 -0500, Jean-Marc Gulliet  
<jeanmarc.gulliet at gmail.com> wrote:

> Daniele wrote:
>> Hello,
>> I'm trying to use the new Manipulate function to evaluate a complex
>> expression. I'm getting a headache, as I'm not familiar with the
>> Mathematica notation (I do most of my work, numerically, with another 
>> system).
>> Maybe somebody here can help debug these few lines?
>>
>> The expression I want to 'manipulate' is the following:
>>
>> MeasuredCMF := VolumeFraction ( EpsilonCell - EpsilonMedium)/
>> ( EpsilonCell + 2 EpsilonMedium)
>>
>> Where VolumeFraction is a parameter, and the other variables are
>> complex and a function of 'f'.
>> They are defined below.
>>
>> omega := 2 Pi f
>> EpsilonCyt := PermittivityCyt - ( ConductivityCyt/omega) I
>> EpsilonMembrane := PermittivityMembrane - (ConductivityMembrane/omega)
>> I
>> EpsilonMedium := PermittivityMedium - (ConductivityMedium/omega) I
>>
>> CMFCell := ( EpsilonCyt - EpsilonMembrane)/( EpsilonCyt + 2
>> EpsilonMembrane)
>> v := CellRadius/(CellRadius - MembraneThickness)
>> EpsilonCell := EpsilonMembrane *(v^3 + 2 CMFCell)/(v^3 - CMFCell)
>>
>> Epsilon0 = 8.85 10^-12;
>> PermittivityCyt = 120 Epsilon0;
>> PermittivityMembrane = 6 Epsilon0;
>> PermittivityMedium = 80 Epsilon0;
>> ConductivityCyt = 0.15;
>> ConductivityMedium = 0.15;
>> ConductivityMembrane = 1 10^-9;
>> CellRadius = 10 10^-6;
>> MembraneThickness = 9 10^-9;
>>
>>
>>  if I define VolumeFraction (eg. VolumeFraction=0.1) and plot
>> Re[MeasuredCMF] vs. f, I have no problem.
>> But I am unable to successfully do the following (I get a blank plot)
>>
>> Manipulate[
>>  LogLinearPlot[
>>   Evaluate[Re[MeasuredCMF]], {f, 1 10^5, 1 10^9}], {{VolumeFraction,
>>    0.2}, 0.1, 0.5}]
>>
>> Can somebody help? I suspect I'm not using the assignment syntax
>> correctly.
>> Thanks
>>
>> Daniele Malleo
>
> Hi Daniele,
>
> Your function definitions are missing the name of one or more variables.
> I have made some modification in your code and and now it should work as
> expected.
>
> MeasuredCMF[vfrac_][f_] :=
>   vfrac*((EpsilonCell[f] - EpsilonMedium[f])/
>          (EpsilonCell[f] + 2*EpsilonMedium[f]))
>
> omega[f_] := 2*Pi*f
>
> EpsilonCyt[f_] := PermittivityCyt - (ConductivityCyt/omega[f])*I
>
> EpsilonMembrane[f_] := PermittivityMembrane -
>       (ConductivityMembrane/omega[f])*I
>
> EpsilonMedium[f_] :=
>   PermittivityMedium - (ConductivityMedium/omega[f])*I
>
> CMFCell[f_] := (EpsilonCyt[f] - EpsilonMembrane[f])/
>       (EpsilonCyt[f] + 2*EpsilonMembrane[f])
>
> v := CellRadius/(CellRadius - MembraneThickness)
>
> EpsilonCell[f_] := EpsilonMembrane[f]*((v^3 + 2*CMFCell[f])/
>          (v^3 - CMFCell[f]))
>
> Epsilon0 = 8.85/10^12;
> PermittivityCyt = 120*Epsilon0;
> PermittivityMembrane = 6*Epsilon0;
> PermittivityMedium = 80*Epsilon0;
> ConductivityCyt = 0.15;
> ConductivityMedium = 0.15;
> ConductivityMembrane = 1/10^9;
> CellRadius = 10/10^6;
> MembraneThickness = 9/10^9;
>
> LogLinearPlot[Evaluate[Re[MeasuredCMF[0.1][f]]], {f, 1*10^5, 1*10^9}]
>
> Manipulate[
>   LogLinearPlot[Evaluate[Re[MeasuredCMF[VolumeFraction][f]]],
>       {f, 1*10^5, 1*10^9}], {{VolumeFraction, 0.2}, 0.1, 0.5}]
>
> Regards,
> Jean-Marc
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: more gripe about the new documentation center (DC) in Mathematica
  • Next by Date: Re: is there a better way to iterate this?
  • Previous by thread: Re: Manipulate a complex expression
  • Next by thread: Re: Manipulate a complex expression