et = (wn *An*Cos[kn x +  phin]*Sin[wn t])^2*(1/
              2 rho)

kn = n Pi /L

wn =  c*kn

c =.

L =.

ep = (1/2 T0)*(kn *An*Sin[kn x +  phin]*
              Cos[wn t])^2

etot = et + ep

Simplify[etot]

T0 = 1

rho = 1

L = 1

Do[Plot[
        Refine[etot, {n == 2, An == 1, phin == Pi}], {x, 0, 
          L}, PlotRange -> {0, 20}], {t, 0,  .5,  .1}]

emean = Integrate[etot, {x, 0, L}]/L

Simplify[%,  n ∈  Integers]

phin =.

Simplify[emean /. n -> 8]

emean /. n -> 1

An =.

Plot[emean, {t, 0, 1}]

kn = n Pi/L

wn =  c * kn

psin = An*Sin[kn x]*Cos[wn t]

vn = D[psin, t]

ecn = (rho/2)*vn^2

dn = D[psin, x]

epn = (T0/2) dn^2

etn = epn + ecn

L = 1

c = 1

rho = 1

T0 = 1

2.  *Pi/wn /. n -> 6

Do[Plot[Refine[ecn, {n == 2, An == 1}], {x, 0, L}, 
        PlotRange -> {0, 30}], {t, 0, 1,  .1}]

Do[Plot[Refine[epn, {n == 2, An == 1}], {x, 0, L}, 
        PlotRange -> {0, 40}], {t, 0,  .5,  .1}]

Do[Plot[{Refine[epn, {n == 6, An == 1}], 
          Refine[ecn, {n == 6, An == 1}]}, {x, 0, L}, 
        PlotRange -> {0, 180}, 
        PlotStyle -> {Hue[0.0], Hue[0.7]}], {t, 0,  .5,  .1}]

Do[Plot[{Refine[psin, {n == 6, An == 100}], 
          Refine[etn, {n == 6, An == 1}]}, {x, 0, L}, 
        PlotRange -> {-100, 180}, 
        PlotStyle -> {Hue[0.0], Hue[0.7]}], {t, 0,  .5,  .1}]

emean = Integrate[etn, {x, 0, L}]

Simplify[emean,  n ∈  Integers]

Simplfy[

Plot[
      Refine[emean, {n == 6, An == 1}], {t, 0, 1}]

psitot = 
      Refine[psin, {n == 2, An == -1/2}] + 
        Refine[psin, {n == 6, An == 1/2}]

vtot = D[psitot, t]

dtot = D[psitot, x]

eectot = (rho/2) vtot^2

eeptot = (T0/2) dtot^2

Do[Plot[{eectot, eeptot}, {x, 0, L}, PlotRange -> {0, 80}, 
        PlotStyle -> {Hue[0.0], Hue[0.7]}], {t, 0,  .5,  .1}]

eetottot = eectot + eeptot

Do[Plot[{100*psitot, eetottot}, {x, 0, L}, 
        PlotRange -> {-100, 100}, 
        PlotStyle -> {Hue[0.0], Hue[ .7]}], {t, 0,  .5,  .1}]

eeptot /. t -> 0

Integrate[eeptot, {x, 0, L}]

% /. t -> 0

eectot /. t -> 0

ettmean = Integrate[eetottot, {x, 0, L}]