Page 1 of 1

rpn_load to set several quads

Posted: 04 Nov 2016, 05:29
by Philippe Piot
Hi,
I have a long FODO lattice. I fit once fodo cell to find the quad strength needed for a specified phase advance and then I would like to set all the quad in the FODO lattice given the value I found for one cell.
I tried to do something like this:

# load the quad associated to one cell
&rpn_load
tag = QUAD450,
filename = fodo.param,
match_column = ElementName,
match_column_value = Q450,
matching_row_number = 1
&end
# set the quad Q470 to same value match as Q450
&alter_elements
name = Q470
item = K1
value = "QUAD450.ParameterValue"
&end

This does not work and I am not sure how to do this. Also is there a way in the rpn_load to actually access the parameter
(now I do it by end using the matching_row_number). Thank you, -- Philippe.

Re: rpn_load to set several quads

Posted: 04 Nov 2016, 08:27
by michael_borland
Philippe,

&rpn_load isn't really intended to do this, but it should work if you try

Code: Select all

...
# set the quad Q470 to same value match as Q450
&alter_elements
name = Q470
item = K1
value = "(QUAD450.ParameterValue)"
&end
An easier method is using &load_parameters, e.g.,

Code: Select all

&load_parameters
	filename = fodo.param,
	include_name_pattern = Q450,
	edit_name_command = %/Q450/Q470/
&end
You can expand this to do multiple replacements, within limits. E.g., if you want to shift values from Q450, Q451, ..., Q459 to Q470, Q471, ..., this would work

Code: Select all

&load_parameters
	filename = fodo.param,
	include_name_pattern = Q45?,
	edit_name_command = %/Q45/Q47/
&end
If you plan to do lots of these operations, I suggest externally processing the fodo.param file.
  1. Create a cross-reference file with two string columns: SourceName and TargetName.
  2. Cross-reference the fodo.param file to get the TargetName for each element
    sddsxref fodo.param xrefFile.sdds fodoMod.param -match=ElementName=SourceName -take=TargetName -reuse=rows
  3. Replace the ElementName in fodoMod.param
    sddsconvert fodoMod.param -delete=column,ElementName -rename=column,TargetName=ElementName
  4. Load fodoMod.param using load_parameters
--Michael

Re: rpn_load to set several quads

Posted: 04 Nov 2016, 14:47
by Philippe Piot
MIchael,
Thank you very much; I was not aware of the capability of the load-parameter. Best, -- Philippe.