Esempio n. 1
0
void
eval_besselj(void)
{
	push(cadr(p1));
	eval();
	push(caddr(p1));
	eval();
	besselj();
}
//---------------------------------------------------------
void MaxwellCurved2D::SetIC()
//---------------------------------------------------------
{
#if (0)
  // NBN: to compare with base version
  // Maxwell2D::SetIC();
  // return;
#endif
  
  // Set initial conditions for simulation

  // First 6 modes of eigenmodes with 6 azimuthal periods
  m_alpha.resize(6);
  m_alpha(1) =  9.936109524217684;
  m_alpha(2) = 13.589290170541217;
  m_alpha(3) = 17.003819667816014;
  m_alpha(4) = 20.320789213566506;
  m_alpha(5) = 23.586084435581391;
  m_alpha(6) = 26.820151983411403;

  // this configuration has an analytic solution
  // Note: analytic sol. depends on m_Ezinit:
  m_bHasAnalyticSol = true;

  // choose radial mode
  alpha0 = m_alpha(2);
  m_theta  = atan2(y,x);
  m_rad    = sqrt(sqr(x) + sqr(y));

//Ez = besselj(6, alpha0*rad).*cos(6*theta);
  DVec tbsslj = besselj(6, alpha0 * m_rad);
  DVec tcosth = apply(cos, (6.0 * m_theta));
  Ezinit = tbsslj.dm(tcosth);

  Ez = Ezinit;
  Hx = 0.0;
  Hy = 0.0;
}
Esempio n. 3
0
int main(void) {
    double complex J0 = besselj(0.0,0.1+0.2*I);
    printf("\nJ0(0.1+0.2i)= %.17f  %+.17f I\n",creal(J0),cimag(J0));

    return 0;
}
Esempio n. 4
0
void
yybesselj(void)
{
	double d;
	int n;

	N = pop();
	X = pop();

	push(N);
	n = pop_integer();

	// numerical result

	if (isdouble(X) && n != (int) 0x80000000) {
		//d = jn(n, X->u.d);
		push_double(d);
		return;
	}

	// bessej(0,0) = 1

	if (iszero(X) && iszero(N)) {
		push_integer(1);
		return;
	}

	// besselj(0,n) = 0

	if (iszero(X) && n != (int) 0x80000000) {
		push_integer(0);
		return;
	}

	// half arguments

	if (N->k == NUM && MEQUAL(N->u.q.b, 2)) {

		// n = 1/2

		if (MEQUAL(N->u.q.a, 1)) {
			push_integer(2);
			push_symbol(PI);
			divide();
			push(X);
			divide();
			push_rational(1, 2);
			power();
			push(X);
			sine();
			multiply();
			return;
		}

		// n = -1/2

		if (MEQUAL(N->u.q.a, -1)) {
			push_integer(2);
			push_symbol(PI);
			divide();
			push(X);
			divide();
			push_rational(1, 2);
			power();
			push(X);
			cosine();
			multiply();
			return;
		}

		// besselj(x,n) = (2/x) (n-sgn(n)) besselj(x,n-sgn(n)) - besselj(x,n-2*sgn(n))

		push_integer(MSIGN(N->u.q.a));
		SGN = pop();

		push_integer(2);
		push(X);
		divide();
		push(N);
		push(SGN);
		subtract();
		multiply();
		push(X);
		push(N);
		push(SGN);
		subtract();
		besselj();
		multiply();
		push(X);
		push(N);
		push_integer(2);
		push(SGN);
		multiply();
		subtract();
		besselj();
		subtract();

		return;
	}


	push(symbol(BESSELJ));
	push(X);
	push(N);
	list(3);
}