Subscripted variables give errors in Module expression [closed]

I have following problem. I want the R not to calculate before the integration but substitute later as a function of z. My Mathematica codes look like:
Codes like big, (sorry) but most of them are just the parameters.

yCal[z_] :=
Module[{ℏ = 1.05*10^-27, e = 4.8*10^-10, c = 3*10^10,
Subscript[ϵ, ∞] = 1.1431, ωd =
1.3202*10^16, γ = 1.0805*10^14,
Subscript[Ω, 1] = 3.8711*10^15,
Subscript[Γ, 1] = 4.4642*10^14,
Subscript[Ω, 2] = 4.1684*10^15,
Subscript[Γ, 2] = 2.3555*10^15,
Subscript[Ï•, 1] = -1.2371, Subscript[Ï•, 2] = -1.0968,
Subscript[A, 1] = 0.26698, Subscript[A, 2] = 3.0834,
Subscript[ϵ, d] = 1, λ = 630*10^-7,
L = 1000*10^-7,
ko = (2 Pi)/(630*10^-7), ω = (2.0*π*3*10^10)/(
630*10^-7), R, Subscript[n, eff], Subscript[α, 1],
Subscript[α, 2], C1, C2, A, ρ, Ez,
Subscript[ϵ, m], MyFun, Pl},
Subscript[n, eff] =
Sqrt[4/(ko^2*((L – z)*Tan[2.2 Degree])^2) (
Subscript[ϵ, d]/Subscript[ϵ, m])/
ProductLog[
Exp[0.577]*Subscript[ϵ, d]/Subscript[ϵ, m]] +
Subscript[ϵ, d]];
Subscript[ϵ, m] =
Subscript[ϵ, ∞] – (ωd^2*ω^2)/(\
ω^4 + γ^2*ω^2) + \!\(
\*UnderoverscriptBox[\(∑\), \(p = 1\), \(2\)]\(
\*SubscriptBox[\(A\), \(p\)]\ \
\*SubscriptBox[\(Ω\), \(p\)] \((
\*FractionBox[\(Cos[
\*SubscriptBox[\(Ï•\), \(p\)]]\ *\((
\*SubscriptBox[\(Ω\), \(p\)] – ω)\) –
\*SubscriptBox[\(Γ\), \(p\)]*Sin[
\*SubscriptBox[\(Ï•\), \(p\)]]\), \(
\*SuperscriptBox[
SubscriptBox[\(Ω\), \(p\)], \(2\)] – 2
\*SubscriptBox[\(Ω\), \(p\)]*ω +
\*SuperscriptBox[\(ω\), \(2\)] +
\*SuperscriptBox[
SubscriptBox[\(Γ\), \(p\)], \(2\)]\)] +
\*FractionBox[\(Cos[
\*SubscriptBox[\(Ï•\), \(p\)]]\ *\((
\*SubscriptBox[\(Ω\), \(p\)] + ω)\) –
\*SubscriptBox[\(Γ\), \(p\)]\ \ *Sin[
\*SubscriptBox[\(Ï•\), \(p\)]]\), \(
\*SuperscriptBox[
SubscriptBox[\(Ω\), \(p\)], \(2\)] + 2
\*SubscriptBox[\(Ω\), \(p\)]*ω +
\*SuperscriptBox[\(ω\), \(2\)] +
\*SuperscriptBox[
SubscriptBox[\(Γ\), \(p\)], \(2\)]\)])\)\)\);
Subscript[α, 1] =
Sqrt[Subscript[n, eff]^2 – Subscript[ϵ, m]];
Subscript[α, 2] =
Sqrt[Subscript[n, eff]^2 – Subscript[ϵ, d]];
C1 = (Abs[BesselK[1, ko*Subscript[α, 1]*R]])^2 Integrate[
Abs[BesselI[1,
ko*Subscript[α, 1] *ρ]]^2*ρ, {ρ, 0, R}];
C2 = (Abs[BesselI[1, ko*Subscript[α, 1]*R]])^2 Integrate[
Abs[BesselK[1,
ko*Subscript[α, 1] *ρ]]^2*ρ, {ρ,
R, ∞}];
With [{A1 = C1, A2 = C2, Ind = Subscript[n, eff]},
A = (Subscript[n, eff]*c)/2*(
Subscript[ϵ, m]*Subscript[ϵ,
d]*(Abs[BesselK[1, ko*Subscript[α, 1]*R]])^2)/(
Subscript[ϵ, d]*Hold@A1 +
Subscript[ϵ, m]*Hold@A2)];
ReleaseHold[A /. R = (L – z)*Tan[2.2 Degree]] ;
MyFun = Integrate[ko*Subscript[n, eff], z];
Ez = (A*Subscript[α, 1])/Subscript[ϵ, m]
BesselI[0, ko*Subscript[α, 1] *ρ] Cos[MyFun]]

I want to calculate Ez.
There is an error about “Local variable specification.” even though there are no variables kept within the Module{}.

=================

=================

1 Answer
1

=================

A minimum working example that reproduces your problem is:

Module[{Subscript[ϵ, ∞] = 1.1431}, Subscript[ϵ, ∞]]

Module::lvset: Local variable specification {Subscript[ϵ, ∞]=1.1431} contains Subscript[ϵ, ∞]=1.1431, which is an assignment to Subscript[ϵ, ∞]; only assignments to symbols are allowed. >>

The message is very clear. You simply can not use subscripted expressions as local variables in Module expression. The fix is to substitute valid identifiers for subscripted expressions.

Module[{ϵ∞ = 1.1431}, ϵ∞]

1.1431