Overview¶
In PHYS Simulation API you can request –via HTTP POST method– a simulation from a list of available simulations. Here we will show you the schemas you need to appropiately request your simulation. In Examples you will see how this works in the real life.
Request a simulation¶
The simulation requests are made in route /api/simulate/{sim_system},
where sim_system is one of the members of
SimSystem.
The body of the request must abide by the following schema
SimRequest¶
Schema needed to request simulations via POST in
|
|||
type |
object |
||
properties |
|||
|
|
||
type |
string |
||
|
T Span |
||
type |
array |
||
default |
|||
items |
type |
number |
|
|
T Eval |
||
type |
array |
||
default |
|||
items |
type |
number |
|
|
T Steps |
||
type |
integer |
||
default |
0 |
||
|
Ini Cndtn |
||
type |
array |
||
default |
|||
items |
type |
number |
|
|
Params |
||
type |
object |
||
additionalProperties |
type |
number |
|
|
|
||
type |
string |
||
|
Username |
||
type |
string |
||
default |
Pepito Perez |
||
definitions |
|||
|
SimSystem |
||
List of available systems for simulation. |
|||
type |
string |
||
enum |
Harmonic-Oscillator, Chen-Lee-Attractor |
||
|
IntegrationMethods |
||
List of available integration methods. For more information see scipy.integrate.solve_ivp. |
|||
type |
string |
||
enum |
RK45, RK23 |
||
The body of the HTML response will have the following schema
SimIdResponse¶
Schema for the response of a simulation request (requested via POST in
route |
||
type |
object |
|
properties |
||
|
Sim Id |
|
type |
string |
|
|
User Id |
|
type |
integer |
|
|
Username |
|
type |
string |
|
|
|
|
type |
string |
|
|
Sim Status Path |
|
type |
string |
|
|
Sim Pickle Path |
|
type |
string |
|
|
Message |
|
type |
string |
|
Request Simulation Status¶
The response of the request simulation (SimIdResponse)
contains a simulation ID, sim_id. In order to know the simulation status you
just need to make an HTTP request via GET with empty body in route
/api/request/status/{sim_id}.
Note
The route will be availble just after the simulation is finished. If you do
not receive a successful response and you are sure about the sim_id you
provided in the API route, the simulation may still be in course.
The schema of the response will be the following
SimStatus¶
Schema of the Simulation Satus. |
|||||
type |
object |
||||
properties |
|||||
|
Sim Id |
||||
type |
string |
||||
|
User Id |
||||
type |
integer |
||||
|
Date |
||||
type |
string |
||||
format |
date-time |
||||
|
|
||||
type |
string |
||||
|
Ini Cndtn |
||||
type |
array |
||||
items |
type |
number |
|||
|
Params |
||||
type |
object |
||||
additionalProperties |
type |
number |
|||
|
|
||||
type |
string |
||||
|
Route Pickle |
||||
type |
string |
||||
|
Route Results |
||||
type |
string |
||||
|
Route Plots |
||||
type |
string |
||||
|
|
||||
type |
array |
||||
items |
anyOf |
|
|||
type |
object |
||||
additionalProperties |
type |
string |
|||
|
|||||
type |
object |
||||
additionalProperties |
type |
string |
|||
|
Plot Query Receipe |
||||
type |
string |
||||
default |
‘route_plots’ + ‘?value=’ + ‘plot_query_value’ |
||||
|
Success |
||||
type |
boolean |
||||
|
Message |
||||
type |
string |
||||
definitions |
|||||
|
SimSystem |
||||
List of available systems for simulation. |
|||||
type |
string |
||||
enum |
Harmonic-Oscillator, Chen-Lee-Attractor |
||||
|
IntegrationMethods |
||||
List of available integration methods. For more information see scipy.integrate.solve_ivp. |
|||||
type |
string |
||||
enum |
RK45, RK23 |
||||
|
PlotQueryValues_HO |
||||
List of tags of each different plot generated automatically by the backend when a Harmonic Oscillator simulation is requested. |
|||||
type |
string |
||||
enum |
coord, phase |
||||
|
PlotQueryValues_ChenLee |
||||
List of tags of each different plot generated automatically by the backend when a Chen-Lee simulation is requested. |
|||||
type |
string |
||||
enum |
threeD, project |
||||
Request Results¶
If success=True in SimStatus, you can
Directly download your results
Download pickle file with all the simulation results as returned by scipy.integrate.solve_ivp. You can do this via GET with empty body in route
/api/results/{sim_id}/pickle.Download your simulation’s automatically generated plots. You can do this via GET with empty body in route
/api/results/{sim_id}/plot?value={plot_query_value}, whereplot_query_valueis one of the items inplot_query_valuesin the simulation status, SimStatus.
See your results online. You can do this via GET in route
/results/{sim_system}/{sim_id}. In the rendered HTML file, you have the option to download both the generated plots and the pickle file mentioned in the last item.