// File: /workspace/github_cpp_makefile_star2_O2/TBody[P]atomicpp/atomicpp/SD1DData.cpp
// Function: atomicpp::SD1DData::SD1DData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, double)
SD1DData::SD1DData(const std::string& expt_results_json, double impurity_fraction_input){

	json data_dict = retrieveFromJSON(expt_results_json);

	impurity_fraction = impurity_fraction_input;

	// # Retrieve (normalised values)
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_Ne = data_dict["Ne"];
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_Nn = data_dict["Nn"];
	std::vector<std::vector<std::vector< std::vector<double> > >> extract_P  = data_dict["P"];

	// // # Retrieve normalisation factors
	double Nnorm = data_dict["Nnorm"];
	double Tnorm = data_dict["Tnorm"];
	// // # Converts N into m^-3, T into eV 

	// Attributes
	// std::vector<double> density;
	// std::vector<double> temperature;
	// std::vector<double> neutral_fraction;
	// double impurity_fraction;
	// std::vector<double> impurity_density;
	
	// Extract the 'y' dimensions, at the final time index
	// Dimensions are [t, x, y, z]
	//                [0, 1, 2, 3]
	int final_time_index = extract_Ne.size() - 1;
	int data_length = extract_Ne[0][0].size();
	
	std::vector<double> shaped_Ne(data_length);
	std::vector<double> shaped_Nn(data_length);
	std::vector<double> shaped_P(data_length);
	std::vector<double> shaped_T(data_length);

	for(int i=0; i< data_length; ++i){
  		shaped_Ne[i] = extract_Ne[final_time_index][0][i][0];
  		shaped_Nn[i] = extract_Nn[final_time_index][0][i][0];
  		shaped_P[i] = extract_P[final_time_index][0][i][0];
		// # P = 2*Ne*Te => Te = P/(2*Ne)
  		shaped_T[i] = shaped_P[i]/(2*shaped_Ne[i]);
	}
	// Verified list copy was identical for Ne
	// N.b. the loops above and below are essentially identical 
	// ways of assigning elements into a std::vector. However, since the 
	// std::vectors below are defined at classdef their length is not
	// initialised, so using push_back method instead.
	
	for(int i=0; i<data_length; ++i){
  		density.push_back(Nnorm * shaped_Ne[i]);
  		temperature.push_back(Tnorm * shaped_T[i]);
  		neutral_fraction.push_back(shaped_Nn[i]/shaped_Ne[i]);
  		impurity_density.push_back(impurity_fraction * density[i]);
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movsd %xmm0, -0x30(%rbp)
movq %rsi, %rbx
movq %rdi, %r14
callq 0x12366
leaq 0x18(%r14), %rdi
movq %rdi, -0x48(%rbp)
callq 0x12366
leaq 0x30(%r14), %rdi
movq %rdi, -0x68(%rbp)
callq 0x12366
movq %r14, -0x40(%rbp)
leaq 0x50(%r14), %rdi
movq %rdi, -0x60(%rbp)
callq 0x12366
leaq -0x140(%rbp), %rdi
movq %rbx, %rsi
callq 0x4480
leaq -0x58(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x5c2c
leaq -0x140(%rbp), %rdi
callq 0x41a0
movq -0x40(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x48(%rax)
leaq 0x70a9(%rip), %rsi      # 0x24040
leaq -0x58(%rbp), %rdi
callq 0xc8b4
leaq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x1d524
leaq 0x708d(%rip), %rsi      # 0x24043
leaq -0x58(%rbp), %rdi
callq 0xc8b4
leaq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0x1d524
leaq 0x7071(%rip), %rsi      # 0x24046
leaq -0x58(%rbp), %rdi
callq 0xc8b4
leaq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x1d524
leaq 0x7054(%rip), %rsi      # 0x24048
leaq -0x58(%rbp), %rdi
callq 0xc8b4
movq %rax, %rdi
callq 0xca1e
movsd %xmm0, -0xc0(%rbp)
leaq 0x703a(%rip), %rsi      # 0x2404e
leaq -0x58(%rbp), %rdi
callq 0xc8b4
movq %rax, %rdi
callq 0xca1e
movsd %xmm0, -0xb8(%rbp)
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
callq 0x1d53c
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
callq 0x17d6c
movq %rax, %rdi
xorl %esi, %esi
callq 0x110d4
movq %rax, %rdi
callq 0x12068
movq %rax, %r13
movslq %r13d, %r14
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x531c
leaq -0xd8(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5326
leaq -0x98(%rbp), %rdi
callq 0x5a64
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
callq 0x531c
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5326
leaq -0xb0(%rbp), %rdi
callq 0x5a64
leaq -0x80(%rbp), %r15
movq %r15, %rdi
callq 0x531c
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5326
leaq -0x80(%rbp), %rdi
callq 0x5a64
leaq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x531c
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5326
leaq -0x38(%rbp), %rdi
callq 0x5a64
decl %ebx
xorl %r15d, %r15d
testl %r13d, %r13d
cmovlel %r15d, %r13d
movslq %ebx, %r12
leaq -0xd8(%rbp), %rbx
leaq -0xb0(%rbp), %r14
cmpq %r15, %r13
je 0x1d263
leaq -0xf0(%rbp), %rdi
movq %r12, %rsi
callq 0x17d6c
movq %rax, %rdi
xorl %esi, %esi
callq 0x110d4
movq %rax, %rdi
movq %r15, %rsi
callq 0x15754
movq %rax, %rdi
xorl %esi, %esi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x120(%rbp), %rdi
movq %r12, %rsi
callq 0x17d6c
movq %rax, %rdi
xorl %esi, %esi
callq 0x110d4
movq %rax, %rdi
movq %r15, %rsi
callq 0x15754
movq %rax, %rdi
xorl %esi, %esi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x98(%rbp), %rdi
movq %r15, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x108(%rbp), %rdi
movq %r12, %rsi
callq 0x17d6c
movq %rax, %rdi
xorl %esi, %esi
callq 0x110d4
movq %rax, %rdi
movq %r15, %rsi
callq 0x15754
movq %rax, %rdi
xorl %esi, %esi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x537c
movsd (%rax), %xmm0
addsd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
movq %r15, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
incq %r15
jmp 0x1d123
xorl %ebx, %ebx
leaq -0xd8(%rbp), %r14
leaq -0x38(%rbp), %r15
leaq -0x98(%rbp), %r12
cmpq %rbx, %r13
je 0x1d346
movq %r14, %rdi
movq %rbx, %rsi
callq 0x537c
movsd (%rax), %xmm0
mulsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0x1d558
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
callq 0x537c
movsd (%rax), %xmm0
mulsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x1d558
movq %r12, %rdi
movq %rbx, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x1d558
movq -0x40(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x1d558
incq %rbx
jmp 0x1d277
leaq -0x80(%rbp), %rdi
callq 0x53a6
leaq -0xb0(%rbp), %rdi
callq 0x53a6
leaq -0x98(%rbp), %rdi
callq 0x53a6
leaq -0xd8(%rbp), %rdi
callq 0x53a6
leaq -0x108(%rbp), %rdi
callq 0x17ce8
leaq -0x120(%rbp), %rdi
callq 0x17ce8
leaq -0xf0(%rbp), %rdi
callq 0x17ce8
leaq -0x58(%rbp), %rdi
callq 0x5e66
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
leaq -0x38(%rbp), %rdi
callq 0x5a64
jmp 0x1d42e
movq %rax, %r13
leaq -0x80(%rbp), %rdi
callq 0x5a64
jmp 0x1d43a
movq %rax, %r13
leaq -0xb0(%rbp), %rdi
callq 0x5a64
jmp 0x1d446
movq %rax, %r13
leaq -0x98(%rbp), %rdi
callq 0x5a64
jmp 0x1d452
movq %rax, %r13
leaq -0x140(%rbp), %rdi
callq 0x41a0
jmp 0x1d47f
movq %rax, %r13
jmp 0x1d47f
jmp 0x1d408
movq %rax, %r13
jmp 0x1d452
movq %rax, %r13
jmp 0x1d45e
movq %rax, %r13
jmp 0x1d46a
movq %rax, %r13
jmp 0x1d476
jmp 0x1d422
jmp 0x1d422
jmp 0x1d422
movq %rax, %r13
leaq -0x80(%rbp), %rdi
callq 0x53a6
leaq -0xb0(%rbp), %rdi
callq 0x53a6
leaq -0x98(%rbp), %rdi
callq 0x53a6
leaq -0xd8(%rbp), %rdi
callq 0x53a6
leaq -0x108(%rbp), %rdi
callq 0x17ce8
leaq -0x120(%rbp), %rdi
callq 0x17ce8
leaq -0xf0(%rbp), %rdi
callq 0x17ce8
leaq -0x58(%rbp), %rdi
callq 0x5e66
movq -0x60(%rbp), %rdi
callq 0x53a6
movq -0x68(%rbp), %rdi
callq 0x53a6
movq -0x48(%rbp), %rdi
callq 0x53a6
movq -0x40(%rbp), %rdi
callq 0x53a6
movq %r13, %rdi
callq 0x45a0
nop