Skip to main content

Starting Simulations & Spending Tokens

A core functionality of the SDK is the ability to start cloud simulations on demand. This page will guide you through how you can start simulations, view the cost of your simulations before starting them and cancelling simulations. This page assumes that one or more simulation definitions have been added to a project, visit our documention on initializing simulations or getting started tutorial such as your first simulation.

Individual simulations

The simulation object is obtained either when the simulation definition is added to the project

simulation = project.add_simulation(sim_def)

The simulation object can also be fetched with the simulation ID or the name

#fetch a simulation from the ID
simulation = project.get_simulation('IDstr')

#fetch a simulation from the name
simulation = project.get_simulation_by_name('namestr')

The IDs and names of the simulations in a given project can be displayed

dd.display(project.get_simulations())

From here the ID's of the individual simulations can be found, along with other high level information about the simulation, such as cut-off frequency, number of receivers, and number of sources.

Token cost of a single simulation

When a simulation has been added to a project, the token cost of that simulation can be viewed

dd.display(simulation.wait_for_token_cost())

Utilizing .wait_for_token_cost() means that the token cost will be provided when the model has been processed in the cloud. The price displayed is the final cost of running the simulation.

Starting a single simulation

An individual simulation can be started with

simulation.start()

Starting the simulation will display the token cost of the simulation along with your token balance after the simulation has run.

A detailed monitoring of the different tasks that makes up a simulation can be done by

simulation.as_live_progress()

Cancelling a single simulation

A simulation can be cancelled by

simulation.cancel()

When a simulation is cancelled by a user, the simulation is stopped in the cloud. The user will be billed for the time the cancelled simulation have run. If a simulation cost 1 token and cancelled after 50% the user will be billed 0.5 token.

Simulations cancelled within 60 seconds of starting do not cost anything.

Multiple simulations in a project

In the SDK you have the option to start all simulations that have not run in a project.

Token cost of a project

The cost of running the simulations in the project can be viewed

dd.display(project.wait_for_token_cost())

The output of the above will be a table with simulation names and IDs

 Project xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx token cost                              
┏━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ Simulation┃ Estimat… ┃ Quoted ┃ Billed ┃
┃Sim ┃ Type ┃ status ┃ runtime ┃ Cost ┃ cost ┃
┡━━━━━━╇━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━┩
│ Sim1 │ GA │ Completed │ 0:00:18 │ │ 0.2
│ Sim2 │ Hybrid │ Completed │ 0:00:50 │ │ 0.68
│ Sim3 │ Hybrid │ Completed │ 0:00:54 │ │ 0.72
│ Sim4 │ Hybrid │ Completed │ 0:00:54 │ │ 0.88
│ Sim6 │ Hybrid │ Canceled │ 0:00:46 │ │ 0
│ Sim7 │ Hybrid │ Completed │ 0:01:22 │ │ 0.74
│ Sim8 │ Hybrid │ Created │ 0:01:220.740
├──────┼────────┼───────────┼──────────┼─────────┼──────────┤
│Total │ │ │ │ 0.743.22
└──────┴────────┴───────────┴──────────┴─────────┴──────────┘

In the above table a collection of simulations can be seen. The completed simulations have been billed to the user, however the cancelled and the created simulation have not. There is no quoted cost for the completed simulations as they have been paid. The quoted cost only contains the amount of tokens it will cost to run the remaining simulations in the project with the simulation status created.

Starting all simulations in a project

All simulation within a project can be started with

project.start_simulations()

Starting the simulations will display the token cost of the simulations along with your token balance after the simulations has run.

Monitoring the progress of all simulations within a project can be done by

simulation.as_live_progress()

Cancelling all simulations in a project

A simulation can be cancelled by

project.cancel_simulations()

When a simulation is cancelled by a user, the simulation is stopped in the cloud. The user will be billed for the time the cancelled simulation have run. If a simulation cost 1 token and cancelled after 50% the user will be billed 0.5 token.

Simulations cancelled within 60 seconds of starting do not cost anything.

Billing prompt configuration

The default in the SDK settings is to print out token cost information when simulations are started with either simulation.start() or project.start_simulation(). It is possible to either turn them of or only have them appear if the total token cost exceeds a certain limit.

To turn of billing related prompts when starting a simulation:

tsdk.config.update_billing_prompts(False)

if you wish to re-enable all billing prompts

tsdk.config.update_billing_prompts(True)

To only have prompts appear above a specified token threshold

tsdk.config.update_billing_prompt_token_limit(token_threshold_int)