// File: TBody[P]atomicpp/atomicpp/RateEquations.cpp
// Function: atomicpp::RateEquations::RateEquations(atomicpp::ImpuritySpecies&, double, double)
RateEquations::RateEquations(ImpuritySpecies& impurity, const double density_threshold /*= 1e9*/, const double mi_in_amu /*= 1*/) : 
	dNzk(impurity.get_atomic_number()+1, 0.0),
	F_zk(impurity.get_atomic_number()+1, 0.0),
	dNzk_correction(impurity.get_atomic_number()+1, 0.0),
	F_zk_correction(impurity.get_atomic_number()+1, 0.0)
	{

	// Set parameters that are useful for multiple functions
	rate_coefficients        = impurity.get_rate_coefficients();
	use_charge_exchange      = impurity.get_has_charge_exchange();
	Z                        = impurity.get_atomic_number();
	mz                       = impurity.get_mass(); //in amu

	Nthres                   = density_threshold;
	mi                       = mi_in_amu;

	//Initialise the outputs
	Pcool                    = 0.0;
	Prad                     = 0.0;
	dNe                      = 0.0;
	F_i                      = 0.0;
	dNn                      = 0.0;
	F_n                      = 0.0;

	//Calculate the factor that doesn't change throughout evaluation
	calculateStoppingTimeConstantFactor();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
callq 0x126b0
movq -0xb8(%rbp), %rax
addq $0x70, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f10
movl %eax, -0xa4(%rbp)
jmp 0x31f7a
movl -0xa4(%rbp), %eax
incl %eax
cltq
movq %rax, -0xd0(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x58a0
movq -0xb0(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rcx
leaq -0x38(%rbp), %rdx
callq 0x26390
jmp 0x31fc3
leaq -0x39(%rbp), %rdi
callq 0x5930
movq -0xc0(%rbp), %rax
addq $0x88, %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f10
movl %eax, -0xd4(%rbp)
jmp 0x31ff1
movl -0xd4(%rbp), %eax
incl %eax
cltq
movq %rax, -0xf0(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x58a0
movq -0xe0(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rcx
leaq -0x48(%rbp), %rdx
callq 0x26390
jmp 0x3203a
leaq -0x49(%rbp), %rdi
callq 0x5930
movq -0xc0(%rbp), %rax
addq $0xa0, %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f10
movl %eax, -0xf4(%rbp)
jmp 0x32068
movl -0xf4(%rbp), %eax
incl %eax
cltq
movq %rax, -0x110(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x58a0
movq -0x100(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rcx
leaq -0x58(%rbp), %rdx
callq 0x26390
jmp 0x320b1
leaq -0x59(%rbp), %rdi
callq 0x5930
movq -0xc0(%rbp), %rax
addq $0xb8, %rax
movq %rax, -0x120(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f10
movl %eax, -0x114(%rbp)
jmp 0x320df
movl -0x114(%rbp), %eax
incl %eax
cltq
movq %rax, -0x130(%rbp)
movq $0x0, -0x68(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x58a0
movq -0x120(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rcx
leaq -0x68(%rbp), %rdx
callq 0x26390
jmp 0x32128
leaq -0x69(%rbp), %rdi
callq 0x5930
movq -0x10(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x11f50
jmp 0x32143
movq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x140(%rbp)
callq 0x35800
movq -0x140(%rbp), %rdi
callq 0x5cf0
movq -0x10(%rbp), %rdi
callq 0x11630
movb %al, -0x131(%rbp)
jmp 0x3217a
movq -0xc0(%rbp), %rax
movb -0x131(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x30(%rax)
movq -0x10(%rbp), %rdi
callq 0x11f10
movl %eax, -0x144(%rbp)
jmp 0x3219e
movq -0xc0(%rbp), %rax
movl -0x144(%rbp), %ecx
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rdi
callq 0x11f30
movsd %xmm0, -0x150(%rbp)
jmp 0x321c1
movq -0xc0(%rbp), %rdi
movsd -0x150(%rbp), %xmm0
movsd %xmm0, 0x38(%rdi)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x40(%rdi)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, 0x48(%rdi)
movq $0x0, 0x60(%rdi)
movq $0x0, 0x68(%rdi)
movq $0x0, 0xd0(%rdi)
movq $0x0, 0xd8(%rdi)
movq $0x0, 0xe0(%rdi)
movq $0x0, 0xe8(%rdi)
movsd 0x7033(%rip), %xmm0     # 0x39260
callq 0x32330
jmp 0x32234
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x32316
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x5930
jmp 0x32316
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x3230a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x5930
jmp 0x3230a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x322fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x5930
jmp 0x322fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x322f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x5930
jmp 0x322f2
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x59b0
movq -0x100(%rbp), %rdi
callq 0x59b0
movq -0xe0(%rbp), %rdi
callq 0x59b0
movq -0xb0(%rbp), %rdi
callq 0x59b0
movq -0xb8(%rbp), %rdi
callq 0x5cf0
movq -0x28(%rbp), %rdi
callq 0x45e0
nopl (%rax,%rax)