accelerInt  v0.1
generate_ics.py
Go to the documentation of this file.
1 
8 
9 import numpy as np
10 
11 # set number of IVPs to solve
12 num = 5000
13 
14 # create data
15 ICs = 2 * np.random.random((num, 2))
16 
17 # set parameters
18 params = 5 * np.random.random((num, 1))
19 
20 # in order to conform to the current read_initial_conditions format, we need
21 # to add a dummy 'time' variable
22 time = np.zeros((num, 1))
23 
24 # finally, we need to concatenate these variables and write to file
25 
26 # again, the current read_initial_conditions format is optimized for pyJac
27 # and expects the state vector to be stored in the form:
28 #
29 # t, y[0], param, y[1]
30 #
31 # This is accomplished via concatentate and some reshapes to get the IC slices
32 # as 2-D arrays
33 #
34 # This format will be updated in future releases
35 
36 out_arr = np.concatenate(
37  (time, np.reshape(ICs[:, 0], (-1, 1)), params,
38  np.reshape(ICs[:, 1], (-1, 1))), axis=1)
39 
40 # and save to file
41 out_arr.tofile('ign_data.bin')