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 /api/request/{sim_system}.

type

object

properties

  • system

SimSystem

type

string

  • t_span

T Span

type

array

default

items

type

number

  • t_eval

T Eval

type

array

default

items

type

number

  • t_steps

T Steps

type

integer

default

0

  • ini_cndtn

Ini Cndtn

type

array

default

items

type

number

  • params

Params

type

object

additionalProperties

type

number

  • method

IntegrationMethods

type

string

  • username

Username

type

string

default

Pepito Perez

definitions

  • SimSystem

SimSystem

List of available systems for simulation.

type

string

enum

Harmonic-Oscillator, Chen-Lee-Attractor

  • IntegrationMethods

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 /api/simulate/{sim_sys}.)

type

object

properties

  • sim_id

Sim Id

type

string

  • user_id

User Id

type

integer

  • username

Username

type

string

  • sim_sys

SimSystem

type

string

  • sim_status_path

Sim Status Path

type

string

  • sim_pickle_path

Sim Pickle Path

type

string

  • message

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

Sim Id

type

string

  • user_id

User Id

type

integer

  • date

Date

type

string

format

date-time

  • system

SimSystem

type

string

  • ini_cndtn

Ini Cndtn

type

array

items

type

number

  • params

Params

type

object

additionalProperties

type

number

  • method

IntegrationMethods

type

string

  • route_pickle

Route Pickle

type

string

  • route_results

Route Results

type

string

  • route_plots

Route Plots

type

string

  • plot_query_values

PlotQueryValues

type

array

items

anyOf

PlotQueryValues_HO

type

object

additionalProperties

type

string

PlotQueryValues_ChenLee

type

object

additionalProperties

type

string

  • plot_query_receipe

Plot Query Receipe

type

string

default

‘route_plots’ + ‘?value=’ + ‘plot_query_value’

  • success

Success

type

boolean

  • message

Message

type

string

definitions

  • SimSystem

SimSystem

List of available systems for simulation.

type

string

enum

Harmonic-Oscillator, Chen-Lee-Attractor

  • IntegrationMethods

IntegrationMethods

List of available integration methods.

For more information see scipy.integrate.solve_ivp.

type

string

enum

RK45, RK23

  • PlotQueryValues_HO

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

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

  1. Directly download your results

    1. 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.

    2. 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}, where plot_query_value is one of the items in plot_query_values in the simulation status, SimStatus.

  2. 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.