Showing results for 
Search instead for 
Do you mean 

System Initialization


I wish you first all the best for the new year

Is there a way to initialize all the variables to 0 (as they would be if I create a new system from scratch)?

I was using "set final values", but I cannot (don't know) how to disable this option.

Thank you in advance




Re: System Initialization

[ Edited ]

Hi mAx,


I wish you a happy new year as well.


I'm afraid this will have to be done manually. Your best bet is to select all the component of the sketch, then in the common parameter window you right click the state variables that you want to reset and select 'Set default'.

An alternative could be to save all the current parameters of the sketch and then edit the saved file to finally reload it.


I hope this helps...



Re: System Initialization

Hi mAx,


wishes of a great year to you too.

if your wish is to initialiaze all the variables then you should stop using the "set final values" option in the solver. The goal of this option is to start the next simulation using the values of your variables at the end of the simulation you previously did.


I believe you only need to untick the option "set final values". I guess the issue here is that you were using this option and saved your model in-between meaning at some point in time your model got these initial variable values set as default.


I think that in that case you should follow the advise of Emmanuel.....

...but by default everytime you start a simulation the variable values is set to "0"...except if you use some of the solver options available....


Hope this helps


Re: System Initialization

Hi mAx,


I wish you a happy and succesful year too.


Additonally to what proposed Emmanuel_D you could also use Python scripting to do that. For example put the few following lines in a Python script (e.g.

from ame_apy import AMESetParameterValue, AMEInitAPI, AMECloseAPI, AMEOpenAmeFile, AMECloseCircuit
from amesim import amegetp, ameloadt, amegetparamuifromname
from os import system
from sys import argv

def getfinalvalues(model_name):

    # Dictionary of ui, names pair of state variables
    state_vars = {}
    # Get all parameters names and values
    par, val = amegetp(model_name)

    # Get all variables names and values
    res_values, res_names = ameloadt(model_name)

    for param_name in par:
        param_name = param_name.replace(' instance ', '_')
        if param_name in res_names:
            submodel = param_name.split('_')[0]
            instance = param_name.split('_')[1].split(' ')[0]
            name = param_name[len(param_name.split(' ')[0])+1:]
            # Translate long names in unique identifier
            state_vars[param_name] = amegetparamuifromname(model_name, submodel, instance, name)[0]
    return state_vars

if __name__ == '__main__':
    model_name = argv[-1]
    system('AMELoad %s' % model_name)
    state_vars = getfinalvalues(model_name)
    system('AMEClean -y %s' % model_name)
    AMEOpenAmeFile(model_name + '.ame')
    for ui in state_vars.values():
        print 'setting ', ui, ' to 0'
        AMESetParameterValue(ui, '0')

Then ensure that you runned at least one simulation and save and close the model from LMS Imagine.Lab Amesim.

Then you can run it with the following command line:

AMEPython mymodel

Where mymodel is the name of the LMS Imagine.Lab Amesim model (hence mymodel.ame).


It will look for all parameters which are also variables and reset the values to 0.


Take care that this script will also reset the constant variables to zero (i.e. in constant sources):


Kind regards

Re: System Initialization

Hello Max,



The "Set final values" option is indeed quite intrusive since it overwrites the initial

values of state variables directly in the circuit. The only way to reverse this mechanism

is to do a backup ("Save configuration", accessible through the "Save" button) before

accepting the "Set final values".



A safer way to start a simulation with the final values is to select the simulation option

"Use old final values". This option is accessible in the "Run parameters" dialog. It is less

intrusive, since if starts the simulation with the final values of the preceeding run, but does

not overwrite what is stored in the circuit.


Best wishes,


Re: System Initialization

thank you for all your replies.

The quickest and fastest workaround is the one from Emmanuel_D

I learned something again today (didn't know the common parameter feature)


@DomiDoes the script also initialize variables in supercomponents which are in the system?


@OliverS Thank you for the explanations with the  Set final values feature (it will surely help)

Re: System Initialization

Hi mAx,


yes I think it should work also with supercomponents.


Best regards