kill(all)$

Elektrochemistry :appendix2 (diff(ψ,x,2) =κ^2*sinh(ψ),version 1.0)
peter.vlasschaert@gmail.com,11/03/2019

problem :  poisson -boltzmann theory   'diffuse double layer'
===================================================
planer surface : one-dimensional case. ( x  = distance, ψ = potential)

see:Elektrochemistry :appendix1 (diff(ψ,x,2) = b*sinh(ψ),version 1.0)
before : b > 0  =>  κ^2 > 0 only case when κ = 0 ( = Laple equation 1D) 

p1:'diff(ψ,x,2) = κ^2*sinh(ψ);

p2:ode2(p1,ψ,x);

solution : 
========

1e) neg : sign.
---------------------

p2a:p2[1];

2e) pos : sign.
---------------------

p2b:p2[2];

definition : cosh(x) ,sinh(x),tanh
===========================

p3a:cosh(x) =exponentialize(cosh(x));

p3b:sinh(x) =exponentialize(sinh(x));

p3c:tanh(x) =exponentialize(tanh(x));

or

p3d:lhs(p3c) = rhs(p3b)/rhs(p3a);

symbolic : hyperbolic trig identities.
==============================

p4:(cosh(xx))^2-(sinh(xx))^2 = trigsimp((cosh(xx))^2-(sinh(xx))^2);

p4a:cosh(2*xx) = trigexpand(cosh(2*xx));
p4b:sinh(2*xx)  = trigexpand(sinh(2*xx));

how to solve. 'p1' 

depends(ψ,x);

p5:p1*diff(ψ,x);

p5a:2*p5;

depends(p,x);

set : dψ/dx   = p

p5b:diff(ψ,x) = 'p;

p5b1:diff(p5b,x);

p5c:subst([p5b,p5b1],p5a);

identity :

p5c1: 'diff(p^2,x) = diff(p^2,x);

p5c2: rhs(p5c1) = lhs(p5c1);

use identity into 'p5c' 

p5d:subst([p5c2],p5c);

subst p =>  rhs 

p5e:lhs(p5d) = subst([rhs(p5b) = lhs(p5b)],rhs(p5d));

from mathematics :

lhs 'p5e'
=======

p5f1:part(lhs(p5e),0);

p5f2:part(lhs(p5e),1);

rhs 'p5e'
=======

p5f3:coeff(rhs(p5e),'diff(ψ,x,1));

combination: 'lhs' and 'rhs'
=======================

p6: p5f2 = 'integrate(p5f3,ψ) +const;

p6a:lhs(p6) = ev(rhs(p6),nouns);

p6b:subst([rhs(p5b) = lhs(p5b)],p6a);

how to find : 'const' from  BC
==========================
BC 1 : ψ         = 0    when  at large distance
BC 2 : dψ/dx = 0    when  at large distance

p7:[ψ = 0,diff(ψ,x) = 0];

use 'p7'  into 'p6b'

p7a:subst(p7,p6b);

solve : const

p7b:solve(p7a,const);

insert : const into 'p6b'

How to find factors
================

p7c:subst(p7b,p6b);

p7c1:lhs(p7c) = collectterms(rhs(p7c),κ^2);;

p7c2:lhs(p7c) =factorout(rhs(p7c),κ^2);

p7c3:factor(p7c);

rem : collectterms works only on one part of the equation.
rem : factorout doesn't work.

two ways  :
=========

1e)  use sqrt

p7d1:sqrt(p7c1);

2e) use solve

p7d2: solve(p7c1,lhs(p5b));

p7d21:p7d2[1];
p7d22:p7d2[2];

what sign  (-) or (+)  ?
==================
---------------------------------------------------------------------------------------
ψ decrease for positive potential with increasing distance.
----------------------------------------------------------------------------------------
=================================================
result : ψ > 0   =>    dψ/dx < 0
=================================================
Answer :
=======
select : (-)

p8: lhs(p5b) = - rhs(p7d1);

from mathematics :

'rhs'

1e)  need  function of 

p8a1a:part(rhs(p8),1,2);

p8a1b:rhs(p8)/p8a1a;

2e)  integration dψ,dx

p8a2:'integrate(1/p8a1a,ψ) ='integrate(p8a1b,x) +const1; 

p8b2:factor(p8a2);

p8b3:subst([abs(κ) = κ],p8b2)/-κ;

p8b4:expand(p8b3);

follows from 'p2a'    =>

p8b5:p2a;

find relation : between 'p8b4' and 'p8b5'
------------------------------------------------------------

?  %k1
======

p9:lhs(p8b4) = lhs(p8b5);

p9a:%k1 = -1;

?  %k2
======

p10:rhs(p8b5) = rhs(p8b4);

p10a:subst([x=0],p10);

?  half angle formula.  'sinh(xx/2)'
===========================

p11:p8a1a;

p11a:factor(p11);

use :symbolic : hyperbolic trig identities.

p11b:p4;

p11b1:solve(p11b,cosh(xx)^2);

p11b2:subst(p11b1,p4a);

p11b3:solve(p11b2,sinh(xx));

select : (+) sign:  why  ψ > 0

p11b4:p11b3[2];

insert  : xx => ψ

p11b5:subst([2*xx=ψ,xx=ψ/2],p11b4);

p11b6:p11b5*sqrt(2);

p11b7:[rhs(p11b6) = lhs(p11b6)];

integration , from above. 'p8b2'

p12:p8b2;

p12a:subst([abs(κ) =κ],expand(p12));

use 'p11b7'

p12b:subst(p11b7,p12a);

p12c:ev(p12b,nouns);

p12c1:logcontract(p12c);

How to find : const1
-------------------------------

condition  :  x = 0   then   ψ  = ψ0

p13:[x=0,ψ = ψ0];;
p13a:subst(p13,p12c1);

p13b:[rhs(p13a) = lhs(p13a)];

final solution . ?
==============
distance : x      = >   x= 0  then  ψ = ψ0
potential : ψ 

p14:subst(p13b,p12c1);

solve :x = ff(ψ,ψ0)
==============

p14a:solve(p14,x)[1];

p14b:logcontract(p14a);

solve: ψ = gg(x,ψ0) 
================

p15:solve(p14,ψ)[1]$

p15a1:pp1=part(rhs(p15),2,1,1);
p15a2:pp2=part(rhs(p15),2,1,2);
p15a3:pp3=part(rhs(p15),2,1,3);
p15a4:pp4=part(rhs(p15),2,1,4);

p15b:lhs(p15) = 2*log(pp1+pp2+pp3+pp4);

-------------------------------------------------------------------------------------------------------------