Package cern.accsoft.steering.jmad.model
Interface JMadModel
-
- All Known Implementing Classes:
JMadModelImpl
public interface JMadModelThis is the facade of a JMad - model It provides methods to retrieve values from the model in a save form and also some wrappers to low-level functions which should be used with care.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(JMadModelListener listener)add a ModelListenervoidcalcOpticsIfDirty()Calculate the optics if the model became dirty.TfsSummarycalcTwissSummary()Function issues a single twiss and returns only the summary of the resulting TfsResult.voidcall(java.io.File file)calls a file from madx.voidcleanup()cleanup all the stuff and free memoryDynapResultdynap(DynapResultRequest dynapResultRequest, TrackInitialCondition trackInitialCondition)run a dynamic aperture test with the given initial condition.voidexecute(java.lang.String cmd)executes the given string directly in madx.OpticsDefinitiongetActiveOpticsDefinition()RangegetActiveRange()RangeDefinitiongetActiveRangeDefinition()AperturegetAperture()java.lang.StringgetDescription()JMadKernelgetKernel()This method retrieves theJMadKernelto which the model sends its commands.KnobManagergetKnobManager()java.util.List<MisalignmentConfiguration>getMisalignments()NOTE: due to incubation form of this method ONLY QUADRUPOLE elements are extracted!ModelModegetMode()JMadModelDefinitiongetModelDefinition()ModelFileFindergetModelFileFinder()java.lang.StringgetName()OpticgetOptics()JMadModelStartupConfigurationgetStartupConfiguration()StrengthVarSetgetStrengthsAndVars()StrengthVarManagergetStrengthVarManager()TwissInitialConditionsgetTwissInitialConditions()doublegetValue(java.lang.String valueName)retrieves the value as defined by its name from madx.java.util.Map<java.lang.String,java.lang.Double>getValueMap(java.util.Collection<java.lang.String> valueNames)reads multiple values from the model given by their names to a map.java.util.List<java.lang.Double>getValues(java.util.List<java.lang.String> valueNames)reads multiple values from the model which are given by their namesvoidinit()inits the values.booleanisInitialized()voidloadAperture()loads all the aperture-files to the model apertureMatchResultmatch(MatchResultRequest resultRequest)Run a MadX Matching Command on the JMad ModelvoidremoveListener(JMadModelListener listener)remove a listenervoidreset()resets the model.voidsaveBeta(java.lang.String name, java.lang.String location, boolean runDummyTwiss)Execute the MadX SaveBeta Function, which saves the Optical Functions Values for a given location with the next twiss command inside MadXvoidsetActiveOpticsDefinition(OpticsDefinition newOpticsDefinition)applies the values of the strengths given by the providedOpticsDefinitionto the model.voidsetActiveRangeDefinition(RangeDefinition rangeDefinition)sets the active range as the range corresponding to the given definitionvoidsetMode(ModelMode modelMode)voidsetStartupConfiguration(JMadModelStartupConfiguration startupConfiguration)voidsetTitle(java.lang.String title)voidsetValue(java.lang.String name, double value)sets a value as defined by its name directly in madx.voidsetValues(java.util.Map<java.lang.String,java.lang.Double> valueNamePairs)sets a List of value - name pairs directly in madxTrackResulttrack(TrackResultRequest trackResultRequest, TrackInitialCondition trackInitialCondition)Do a tracking with the given initial condition.TfsResulttwiss(TfsResultRequest resultRequest)runs the twiss with the given given ResultRequest and the initial conditions defined in the model.TfsResulttwiss(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions)runs the twiss with the given initial conditions.TfsResulttwissToFile(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions, java.io.File tfsFile)run a twiss with the given initial conditions.TfsResulttwissToFile(TfsResultRequest resultRequest, java.io.File tfsFile)run a twiss with the given given ResultRequest and the initial conditions defined in the model and write to file.
-
-
-
Method Detail
-
getName
java.lang.String getName()
- Returns:
- the name of the model containing
- ModelDefinition Name
- current Sequence Name
-
getDescription
java.lang.String getDescription()
- Returns:
- the current description of the Model containing
- ModelDefinition Name
- current Sequence Name
- current Range Name
- current Optic Name
-
getModelDefinition
JMadModelDefinition getModelDefinition()
- Returns:
- the model-definition, from which the model was created.
-
setActiveRangeDefinition
void setActiveRangeDefinition(RangeDefinition rangeDefinition) throws JMadModelException
sets the active range as the range corresponding to the given definition- Parameters:
rangeDefinition- theRangeDefinitionwhich shall be used to set the newly active range- Throws:
JMadModelException- if the change of the range fails
-
setActiveOpticsDefinition
void setActiveOpticsDefinition(OpticsDefinition newOpticsDefinition) throws JMadModelException
applies the values of the strengths given by the providedOpticsDefinitionto the model. after loading of the optic it reloads the activeRangeDefinition. This behavior is necessary, as some of the optics require re-matching of both beams combined. That can result in a different Range being active after the loading of the optics.- Parameters:
newOpticsDefinition- the optics definition to set as the active one- Throws:
JMadModelException- in case setting the active range fails
-
getActiveOpticsDefinition
OpticsDefinition getActiveOpticsDefinition()
- Returns:
- the actually used
OpticsDefinition, ornullif no optic is loaded.
-
getActiveRangeDefinition
RangeDefinition getActiveRangeDefinition()
- Returns:
- the currently active
RangeDefinition
-
getKnobManager
KnobManager getKnobManager()
- Returns:
- the manager, which contains all the model specific knobs.
-
init
void init() throws JMadModelException
inits the values. Does not initialize the elements!- Throws:
JMadModelException- if the initialization fails
-
isInitialized
boolean isInitialized()
- Returns:
- true, if the model is correctly initialized, false if not
-
reset
void reset() throws JMadModelExceptionresets the model. Preserves the elements-state: if they are initialized, they will be reinitialized, otherwise not.- Throws:
JMadModelException- if the reset fails
-
cleanup
void cleanup() throws JMadModelExceptioncleanup all the stuff and free memory- Throws:
JMadModelException- if the cleanup fails
-
twiss
TfsResult twiss(TfsResultRequest resultRequest) throws JMadModelException
runs the twiss with the given given ResultRequest and the initial conditions defined in the model.- Parameters:
resultRequest- the requested result- Returns:
- the result of the twiss
- Throws:
JMadModelException- if the twiss calculations fail
-
twissToFile
TfsResult twissToFile(TfsResultRequest resultRequest, java.io.File tfsFile) throws JMadModelException
run a twiss with the given given ResultRequest and the initial conditions defined in the model and write to file.- Parameters:
resultRequest- the requested resulttfsFile- the file to write the twiss to- Returns:
- The tfsresult from the twiss
- Throws:
JMadModelException- if the twiss calculations fail
-
twiss
TfsResult twiss(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions) throws JMadModelException
runs the twiss with the given initial conditions. NOTE: This changes nothing in the state of the model- Parameters:
resultRequest- the requested resulttwissInitialConditions- the initial conditions to use- Returns:
- the result of the twiss
- Throws:
JMadModelException- if the twiss calculations fail
-
twissToFile
TfsResult twissToFile(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions, java.io.File tfsFile) throws JMadModelException
run a twiss with the given initial conditions. And write to file. NOTE: This changes nothing in the state of the model- Parameters:
resultRequest- the requested resulttwissInitialConditions- the initial conditions to usetfsFile- the file to write the twiss to- Returns:
- The tfs result, which is also written to the file
- Throws:
JMadModelException- if the twiss calculations fail
-
getTwissInitialConditions
TwissInitialConditions getTwissInitialConditions()
- Returns:
- the actual twiss initial-conditions. These can be changed in order to start subsequent twiss-commands with the new initial conditions.
-
track
TrackResult track(TrackResultRequest trackResultRequest, TrackInitialCondition trackInitialCondition) throws JMadModelException
Do a tracking with the given initial condition. Note : This changes nothing in the state of the model- Parameters:
trackResultRequest-trackInitialCondition-- Returns:
- The result from the tracking
- Throws:
JMadModelException- if tracking fails
-
dynap
DynapResult dynap(DynapResultRequest dynapResultRequest, TrackInitialCondition trackInitialCondition) throws JMadModelException
run a dynamic aperture test with the given initial condition. Note : This changes nothing to the stat of the model- Parameters:
dynapResultRequest-trackInitialCondition-- Returns:
- The result from the dynap command
- Throws:
JMadModelException- if the command fails
-
calcOpticsIfDirty
void calcOpticsIfDirty() throws JMadModelExceptionCalculate the optics if the model became dirty.- Throws:
JMadModelException- if the calculation of the optics fails
-
getOptics
Optic getOptics() throws JMadModelException
- Returns:
- the actual optics values for all elements in the active range.
- Throws:
JMadModelException- if the calculation of the optics fails
-
addListener
void addListener(JMadModelListener listener)
add a ModelListener- Parameters:
listener- the listener to add
-
removeListener
void removeListener(JMadModelListener listener)
remove a listener- Parameters:
listener- the listener to remove
-
getKernel
JMadKernel getKernel()
This method retrieves theJMadKernelto which the model sends its commands. Use with care!- Returns:
- the kernel of the model.
-
call
void call(java.io.File file)
calls a file from madx.- Parameters:
file- the file to call
-
execute
void execute(java.lang.String cmd)
executes the given string directly in madx. (must also contain ";" at the end!) Use with care!- Parameters:
cmd- the string to execute
-
setValue
void setValue(java.lang.String name, double value) throws JMadModelExceptionsets a value as defined by its name directly in madx.- Parameters:
name- the name of the value to setvalue- the value to set- Throws:
JMadModelException- if setting the value to MadX fails
-
setValues
void setValues(java.util.Map<java.lang.String,java.lang.Double> valueNamePairs) throws JMadModelExceptionsets a List of value - name pairs directly in madx- Parameters:
valueNamePairs- the Map containing madx parameter names and values to assign- Throws:
JMadModelException- if setting the values to MadX fails
-
getValue
double getValue(java.lang.String valueName) throws JMadModelExceptionretrieves the value as defined by its name from madx.- Parameters:
valueName- the name of the value- Returns:
- the actual value
- Throws:
JMadModelException- if the retrieval of the values fails
-
getValues
java.util.List<java.lang.Double> getValues(java.util.List<java.lang.String> valueNames) throws JMadModelExceptionreads multiple values from the model which are given by their names- Parameters:
valueNames- the names of the values to read- Returns:
- the values
- Throws:
JMadModelException- if the retrieval of the values fails
-
getValueMap
java.util.Map<java.lang.String,java.lang.Double> getValueMap(java.util.Collection<java.lang.String> valueNames) throws JMadModelExceptionreads multiple values from the model given by their names to a map. The non-null map contains the mappings between valueName and read value, if the read operation was successful.- Parameters:
valueNames- the names of the values to read- Returns:
- a guaranteed non-null map, containing the mappings of the read values
- Throws:
JMadModelException
-
match
MatchResult match(MatchResultRequest resultRequest) throws JMadModelException
Run a MadX Matching Command on the JMad ModelIf no Sequence is specified in the
MatchResultRequestthe actual Sequence will be used for matching as enabled with the last setActiveRange command.After the Matching changes to the model are updated accordingly
- Parameters:
resultRequest- the Matching Request containing relevant parameters- Returns:
- the
MatchResultas retrieved from MadX - Throws:
JMadModelException- if the matching fails
-
saveBeta
void saveBeta(java.lang.String name, java.lang.String location, boolean runDummyTwiss) throws JMadModelExceptionExecute the MadX SaveBeta Function, which saves the Optical Functions Values for a given location with the next twiss command inside MadX- Parameters:
name- the MadX internal Name for the SaveBetalocation- the location in the sequence where to save the Optical Functions ValuesrunDummyTwiss- if true a 'twiss;' command is send directly after the saveBeta- Throws:
JMadModelException
-
calcTwissSummary
TfsSummary calcTwissSummary() throws JMadModelException
Function issues a single twiss and returns only the summary of the resulting TfsResult. This is nothing else than a shortcut totwiss(TfsResultRequest.createSummaryOnlyRequest()).getSummary()- Returns:
- the summary part of the actually valid twiss result.
- Throws:
JMadModelException- if the twiss fails.
-
loadAperture
void loadAperture() throws JMadModelExceptionloads all the aperture-files to the model aperture- Throws:
JMadModelException- if loading of the aperture fails
-
getAperture
Aperture getAperture()
- Returns:
- the actually loaded aperture
-
getStrengthsAndVars
StrengthVarSet getStrengthsAndVars()
- Returns:
- the actually valid strengths and variables.
-
getModelFileFinder
ModelFileFinder getModelFileFinder()
- Returns:
- the model file finder
-
getStartupConfiguration
JMadModelStartupConfiguration getStartupConfiguration()
- Returns:
- the startup configuration which will be used when initializing and resetting the model
-
setStartupConfiguration
void setStartupConfiguration(JMadModelStartupConfiguration startupConfiguration)
- Parameters:
startupConfiguration- the new startup-configuration
-
setMode
void setMode(ModelMode modelMode)
- Parameters:
modelMode- defines if normal madx or ptc is used
-
getMode
ModelMode getMode()
- Returns:
- the current mode
-
setTitle
void setTitle(java.lang.String title)
- Parameters:
title- the title to set in MadX for the following twiss-commands
-
getMisalignments
java.util.List<MisalignmentConfiguration> getMisalignments()
NOTE: due to incubation form of this method ONLY QUADRUPOLE elements are extracted!- Returns:
- a complete list of an actual machine imperfections accordingly to the requested definition (see:
RangeaddMisalignments(), addMisalignment())
-
getStrengthVarManager
StrengthVarManager getStrengthVarManager()
-
-