Replies: 4 comments 17 replies
-
Hi Albert, it is possible to do that. You will basically need all state variables (including Voltage) for the ODEs of each node. There is a function in matrix_assembly.c called set_initial_conditions_from_odes. This function sets the tissue voltage according to the ODEs voltage. So, you will have to use this function as the init_function in the [assembly_matrix] section. Now, the hardest part is to restore the ODEs values. In order to do that, you will have to create an extra_data function that will assemble [V1, V2, V3, S1_1, S1_2, S1_3, S2_1, S2_2, S2_3, S3_1, S3_2, S3_3] where V1, V2, V3 are the voltage values for the 3 cells. Si_j is the state variable i for cell j. After returning the vector in the extra_data function, you can write the set_model_initial_conditions_gpu as: extern "C" SET_ODE_INITIAL_CONDITIONS_GPU(set_model_initial_conditions_gpu) {
uint32_t num_volumes = solver->original_num_cells;
// execution configuration
const int GRID = (num_volumes + BLOCK_SIZE - 1)/BLOCK_SIZE;
size_t size = num_volumes*sizeof(real);
check_cuda_error(cudaMallocPitch((void **) &(solver->sv), &pitch_h, size, (size_t )NEQ));
check_cuda_error(cudaMemcpyToSymbol(pitch, &pitch_h, sizeof(size_t)));
real *initial_conditions = NULL;
real *initial_conditions_device = NULL;
if(solver->ode_extra_data) {
initial_conditions = (real *)solver->ode_extra_data;
check_cuda_error(cudaMemcpy2D (solver->sv, pitch_h, initial_conditions, size, size, (size_t) NEQ, cudaMemcpyHostToDevice));
}
else {
kernel_set_model_inital_conditions <<<GRID, BLOCK_SIZE>>>(solver->sv, num_volumes);
}
check_cuda_error( cudaPeekAtLastError() );
cudaDeviceSynchronize();
check_cuda_error(cudaFree(initial_conditions_device));
return pitch_h;
} I hope this helps. Let me know if you have any further questions. My best. |
Beta Was this translation helpful? Give feedback.
-
Hey Rafael, Do you think it would be better to pass the vector of state variables as a text file? Or include the state variables as different columns in the ".alg" file and generate a function to enssemble the vector later? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi Abert, Hope it helps, My best, |
Beta Was this translation helpful? Give feedback.
-
Could you tell me your thoughts about the following struct? I am reading the state variables from a column array in the form: n = num_active_cells |
Beta Was this translation helpful? Give feedback.
-
Hey,
Here Albert,
I was wondering whether it would be possible to "create" a state that can be restored for future simulations, but without running the previous simulation and saving state. That is, providing that I have the voltage values for every node and all parameters for the simulation, can I create a "mock" state that I can restore?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions