hexagon logo

What is python command if I want to modify the value of a design variable? e.g. DV1 exists in database with current value 10, want to change to 20

What is python command if I want to modify the value of a design variable?
e.g. DV1 exists in database with current value 10, want to change to 20
  • The most straight forward would be
     Adams.execute_cmd("var set var=DV_1 real=20.0")
     
  • Thanks for reply and it worked.
    I want to extend here more little bit,
     
    I have created cmd script where value of design variable is changed 1 unit until last value and solver files are exported
    if condition=(DB_EXISTS("ip"))
      variable modify variable= ip & 
      integer = 0
    else
      variable create variable= ip & 
      integer = 0
    end
    while condition=(ip < 5)
    variable modify variable_name=ip integer_value=(eval(ip+1))
    variable modify variable= DV_1 &
    real = (eval(ip))
    simulation set solver_preference = write_files_only
    simulation set file_prefix = (eval("iteration_" // RTOI(ip)//"D"))
    simulation single scripted &
       sim_script_name = SIM_SCRIPT_1 
    end
    variable modify variable_name=ip integer_value=0
     
    how to use interval value such as 0.5 or 0.2 like that instead of 1 or 2.
     
    and how to do script with python loops as well.
     
    thanks
  • You don't need the first IF statement. Just use
    variable set variable = ip integer =0
    "variable set" will create the variable if it doesn't exist and modify it if it does.
    If you want to use 0.2 or 0.5, just do it. But ip must be a real variable, not integer. And then you can't really use it for naming.
     
  • For a real "interval" you simply introduce a second variable.
     
    var set var = interval real = 0.2
    while condition=(ip < 5)
    variable set variable_name=ip integer_value=(eval( (ip+1) ))
    variable set variable= (eval("DV_"" // ip)) &
    real = (eval(ip*interval))