// File: 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
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x170(%rbp)
movq %rdi, %rax
movq %rax, -0x188(%rbp)
callq 0x1cee0
movq -0x170(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x180(%rbp)
callq 0x1cee0
movq -0x170(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x178(%rbp)
callq 0x1cee0
movq -0x170(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x168(%rbp)
callq 0x1cee0
movq -0x10(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x4190
jmp 0x2ffd6
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6c20
jmp 0x2ffe5
leaq -0x48(%rbp), %rdi
callq 0x4220
movq -0x188(%rbp), %rax
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x48(%rax)
leaq 0x9244(%rip), %rsi      # 0x3924a
leaq -0x28(%rbp), %rdi
callq 0x12e00
movq %rax, -0x190(%rbp)
jmp 0x30018
movq -0x190(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x308c0
jmp 0x3002a
leaq 0x921c(%rip), %rsi      # 0x3924d
leaq -0x28(%rbp), %rdi
callq 0x12e00
movq %rax, -0x198(%rbp)
jmp 0x30043
movq -0x198(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x308c0
jmp 0x30058
leaq 0x91f1(%rip), %rsi      # 0x39250
leaq -0x28(%rbp), %rdi
callq 0x12e00
movq %rax, -0x1a0(%rbp)
jmp 0x30071
movq -0x1a0(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x308c0
jmp 0x30086
leaq 0x91c5(%rip), %rsi      # 0x39252
leaq -0x28(%rbp), %rdi
callq 0x12e00
movq %rax, -0x1a8(%rbp)
jmp 0x3009f
movq -0x1a8(%rbp), %rdi
callq 0x13070
movsd %xmm0, -0x1b0(%rbp)
jmp 0x300b5
movsd -0x1b0(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
leaq 0x918c(%rip), %rsi      # 0x39258
leaq -0x28(%rbp), %rdi
callq 0x12e00
movq %rax, -0x1b8(%rbp)
jmp 0x300de
movq -0x1b8(%rbp), %rdi
callq 0x13070
movsd %xmm0, -0x1c0(%rbp)
jmp 0x300f4
movsd -0x1c0(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x308f0
movq -0x1e0(%rbp), %rdi
decl %eax
movl %eax, -0xb4(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x1d8(%rbp)
callq 0x268e0
movq -0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x1ac80
movq %rax, %rdi
callq 0x1c8b0
movl %eax, -0xb8(%rbp)
movslq -0xb8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x58a0
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x58c0
jmp 0x3018d
leaq -0xd1(%rbp), %rdi
callq 0x5930
movslq -0xb8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x58a0
movq -0x1f0(%rbp), %rsi
movq -0x1e8(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x58c0
jmp 0x301d6
leaq -0xf1(%rbp), %rdi
callq 0x5930
movslq -0xb8(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0x111(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x58a0
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x110(%rbp), %rdi
callq 0x58c0
jmp 0x3021f
leaq -0x111(%rbp), %rdi
callq 0x5930
movslq -0xb8(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x58a0
movq -0x210(%rbp), %rsi
movq -0x208(%rbp), %rdx
leaq -0x130(%rbp), %rdi
callq 0x58c0
jmp 0x30268
leaq -0x131(%rbp), %rdi
callq 0x5930
movl $0x0, -0x138(%rbp)
movl -0x138(%rbp), %eax
cmpl -0xb8(%rbp), %eax
jge 0x30524
movslq -0xb4(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x268e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ac80
movq %rax, %rdi
movslq -0x138(%rbp), %rsi
callq 0x22870
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x238(%rbp)
movslq -0x138(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5950
movsd -0x238(%rbp), %xmm0
movsd %xmm0, (%rax)
movslq -0xb4(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x268e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ac80
movq %rax, %rdi
movslq -0x138(%rbp), %rsi
callq 0x22870
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x230(%rbp)
movslq -0x138(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5950
movsd -0x230(%rbp), %xmm0
movsd %xmm0, (%rax)
movslq -0xb4(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x268e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ac80
movq %rax, %rdi
movslq -0x138(%rbp), %rsi
callq 0x22870
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x228(%rbp)
movslq -0x138(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5950
movsd -0x228(%rbp), %xmm0
movsd %xmm0, (%rax)
movslq -0x138(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x220(%rbp)
movslq -0x138(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5950
movsd -0x220(%rbp), %xmm0
movsd 0x8762(%rip), %xmm1     # 0x38b60
mulsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x218(%rbp)
movslq -0x138(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x5950
movsd -0x218(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x3027e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x307a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4220
jmp 0x307a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3079a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x30791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x30785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x30779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x5930
jmp 0x30779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x5930
jmp 0x3076d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x111(%rbp), %rdi
callq 0x5930
jmp 0x30761
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x131(%rbp), %rdi
callq 0x5930
jmp 0x30755
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0xb8(%rbp), %eax
jge 0x306f2
movq -0x188(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x240(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x248(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5950
movsd -0x248(%rbp), %xmm0
movq -0x240(%rbp), %rdi
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
leaq -0x148(%rbp), %rsi
callq 0x30920
jmp 0x305a2
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x250(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x5950
movsd -0x250(%rbp), %xmm0
movq -0x188(%rbp), %rdi
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
leaq -0x150(%rbp), %rsi
callq 0x30920
jmp 0x305f2
movq -0x188(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x258(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x260(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x5950
movsd -0x260(%rbp), %xmm0
movq -0x258(%rbp), %rdi
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
leaq -0x158(%rbp), %rsi
callq 0x30920
jmp 0x30663
movq -0x188(%rbp), %rdi
movq %rdi, %rax
addq $0x50, %rax
movq %rax, -0x268(%rbp)
movsd 0x48(%rdi), %xmm0
movsd %xmm0, -0x270(%rbp)
addq $0x18, %rdi
movslq -0x13c(%rbp), %rsi
callq 0x5950
movsd -0x270(%rbp), %xmm0
movq -0x268(%rbp), %rdi
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
leaq -0x160(%rbp), %rsi
callq 0x30920
jmp 0x306c2
jmp 0x306c4
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x3052e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x59b0
jmp 0x30755
leaq -0x130(%rbp), %rdi
callq 0x59b0
leaq -0x110(%rbp), %rdi
callq 0x59b0
leaq -0xf0(%rbp), %rdi
callq 0x59b0
leaq -0xd0(%rbp), %rdi
callq 0x59b0
leaq -0xa0(%rbp), %rdi
callq 0x26820
leaq -0x88(%rbp), %rdi
callq 0x26820
leaq -0x70(%rbp), %rdi
callq 0x26820
leaq -0x28(%rbp), %rdi
callq 0x6fd0
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
leaq -0x110(%rbp), %rdi
callq 0x59b0
leaq -0xf0(%rbp), %rdi
callq 0x59b0
leaq -0xd0(%rbp), %rdi
callq 0x59b0
leaq -0xa0(%rbp), %rdi
callq 0x26820
leaq -0x88(%rbp), %rdi
callq 0x26820
leaq -0x70(%rbp), %rdi
callq 0x26820
leaq -0x28(%rbp), %rdi
callq 0x6fd0
movq -0x168(%rbp), %rdi
callq 0x59b0
movq -0x178(%rbp), %rdi
callq 0x59b0
movq -0x180(%rbp), %rdi
callq 0x59b0
movq -0x170(%rbp), %rdi
callq 0x59b0
movq -0x50(%rbp), %rdi
callq 0x45e0
nopl (%rax)