Computational Science Based on HPC
Functions
oscserial.h File Reference

This file contains the implementation of the serial version of the oscillation simulation in 1D and 2D. More...

Go to the source code of this file.

Functions

char * _simulate_damped_os_serial (double max_amplitude, double length, double mass, double gravity, double k, double Ao, double Vo, double FI, double time_limit, double step_size, double damping_coefficent, int number_of_files)
 This function simulates simple harmonic motion (Simple Spring Motion).
 
char * _execution_time_damped_os_serial (double max_amplitude, double length, double mass, double gravity, double k, double Ao, double Vo, double FI, double time_limit, double step_size, double damping_coefficent, int number_of_files)
 This function calculates execution time of simulating simple harmonic motion (Simple Spring Motion).
 
char * _simulate_elastic_pendulum (double r, double length, double mass, double gravity, double k, double Ao, double Xo, double Yo, double Vo, double time_limit, double step_size, double damping_coefficent, int number_of_files)
 This function simulates the motion of (elastic pendulum/2D-spring/spring pendulum) system.
 
char * _execution_time_elastic_pendulum (double r, double length, double mass, double gravity, double k, double Ao, double Xo, double Yo, double Vo, double time_limit, double step_size, double damping_coefficent, int number_of_files)
 This function calculates the execution time of simulating the motion of (elastic pendulum/2D-spring/spring pendulum) system.
 

Detailed Description

This file contains the implementation of the serial version of the oscillation simulation in 1D and 2D.

Function Documentation

◆ _execution_time_damped_os_serial()

char * _execution_time_damped_os_serial ( double  max_amplitude,
double  length,
double  mass,
double  gravity,
double  k,
double  Ao,
double  Vo,
double  FI,
double  time_limit,
double  step_size,
double  damping_coefficent,
int  number_of_files 
)

This function calculates execution time of simulating simple harmonic motion (Simple Spring Motion).

using numerical solution of stepwise precision using equation (e^(-damping_coefficent / (2 * mass)) * t)*sin(wt+fi)), where this equation calculates the displacement of mass on y-axis, this function also calculates the acceleration and velocity in each time step. This function is implemented using serial algorithm.

Warning
don't set gravity less than 0.
if max_amplitude is greater than the length the max_amplitude automatically set to the length value
Parameters
max_amplitudestarting position of the mass where the simulation will start
lengththe maximum length of the spring (uncompressed spring)
massmass of bob
gravity
kstiffness of the spring
Aoinitial acceleration
Voinitial velocity
FIFI constant which will be added to the (wt) inside the sine calculation
time_limitthe time when the simulation will stop
step_sizehow much the simulation will skip per iteration
damping_coefficentdamping factor affecting on the system
number_of_files
Returns
execution time of simulation

◆ _execution_time_elastic_pendulum()

char * _execution_time_elastic_pendulum ( double  r,
double  length,
double  mass,
double  gravity,
double  k,
double  Ao,
double  Xo,
double  Yo,
double  Vo,
double  time_limit,
double  step_size,
double  damping_coefficent,
int  number_of_files 
)

This function calculates the execution time of simulating the motion of (elastic pendulum/2D-spring/spring pendulum) system.

Using LaGrange mechanics to get the equation of motion of the whole system and solving the differential equation using Fourth order Runge-Kutta ODE to get the displacement of body suspended on spring at time t. This system's motion is chaotic motion so it can't be parallelized. This simulation prints the position of mass w.r.t X-Axis and Y-Axis.

Warning
don't set gravity less than 0.
if sqrt(Yo^2 + Xo^2) is greater than the length the Xo = sqrt(length ^ 2 - Yo ^ 2).
Parameters
rrest length of spring
lengthmax length of spring
massmass of bob suspended in spring
gravity
kstiffness of spring
Aoinitial acceleration
Xoinitial point on X-axis where simulation starts
Yoinitial point on Y-axis where simulation starts
Voinitial velocity
time_limitthe time when the simulation will stop
step_sizehow much the simulation will skip per iteration
damping_coefficentdamping factor affecting on the system
number_of_files
Returns
execution time if simulation

◆ _simulate_damped_os_serial()

char * _simulate_damped_os_serial ( double  max_amplitude,
double  length,
double  mass,
double  gravity,
double  k,
double  Ao,
double  Vo,
double  FI,
double  time_limit,
double  step_size,
double  damping_coefficent,
int  number_of_files 
)

This function simulates simple harmonic motion (Simple Spring Motion).

using numerical solution of stepwise precision using equation (e^(-damping_coefficent / (2 * mass)) * t)*sin(wt+fi)), where this equation calculates the displacement of mass on y-axis, this function also calculates the acceleration and velocity in each time step. This function is implemented using serial algorithm.

Warning
don't set gravity less than 0.
if max_amplitude is greater than the length the max_amplitude automatically set to the length value
Parameters
max_amplitudestarting position of the mass where the simulation will start
lengththe maximum length of the spring (uncompressed spring)
massmass of bob
gravity
kstiffness of the spring
Aoinitial acceleration
Voinitial velocity
FIFI constant which will be added to the (wt) inside the sine calculation
time_limitthe time when the simulation will stop
step_sizehow much the simulation will skip per iteration
damping_coefficentdamping factor affecting on the system
number_of_files
Returns
integer value 0 if the program executes without any errors -1 if there is an error occurred during calculations

◆ _simulate_elastic_pendulum()

char * _simulate_elastic_pendulum ( double  r,
double  length,
double  mass,
double  gravity,
double  k,
double  Ao,
double  Xo,
double  Yo,
double  Vo,
double  time_limit,
double  step_size,
double  damping_coefficent,
int  number_of_files 
)

This function simulates the motion of (elastic pendulum/2D-spring/spring pendulum) system.

Using LaGrange mechanics to get the equation of motion of the whole system and solving the differential equation using Fourth order Runge-Kutta ODE to get the displacement of body suspended on spring at time t. This system's motion is chaotic motion so it can't be parallelized. This simulation prints the position of mass w.r.t X-Axis and Y-Axis.

Warning
don't set gravity less than 0.
if sqrt(Yo^2 + Xo^2) is greater than the length the Xo = sqrt(length ^ 2 - Yo ^ 2).
Parameters
rrest length of spring
lengthmax length of spring
massmass of bob suspended in spring
gravity
kstiffness of spring
Aoinitial acceleration
Xoinitial point on X-axis where simulation starts
Yoinitial point on Y-axis where simulation starts
Voinitial velocity
time_limitthe time when the simulation will stop
step_sizehow much the simulation will skip per iteration
damping_coefficentdamping factor affecting on the system
number_of_files
Returns
integer value 0 if the program executes without any errors -1 if there is an error occurred during calculations