Interface JMadModel

  • All Known Implementing Classes:
    JMadModelImpl

    public interface JMadModel
    This 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 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 - the RangeDefinition which 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 provided OpticsDefinition to the model. after loading of the optic it reloads the active RangeDefinition. 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
      • getActiveRange

        Range getActiveRange()
        Returns:
        the currently active Range
      • getKnobManager

        KnobManager getKnobManager()
        Returns:
        the manager, which contains all the model specific knobs.
      • isInitialized

        boolean isInitialized()
        Returns:
        true, if the model is correctly initialized, false if not
      • reset

        void reset()
            throws JMadModelException
        resets the model. Preserves the elements-state: if they are initialized, they will be reinitialized, otherwise not.
        Throws:
        JMadModelException - if the reset 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 result
        tfsFile - 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 result
        twissInitialConditions - 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 result
        twissInitialConditions - the initial conditions to use
        tfsFile - 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.
      • calcOpticsIfDirty

        void calcOpticsIfDirty()
                        throws JMadModelException
        Calculate the optics if the model became dirty.
        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 the JMadKernel to 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 JMadModelException
        sets a value as defined by its name directly in madx.
        Parameters:
        name - the name of the value to set
        value - 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 JMadModelException
        sets 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 JMadModelException
        retrieves 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 JMadModelException
        reads 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 JMadModelException
        reads 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 Model

        If no Sequence is specified in the MatchResultRequest the 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 MatchResult as retrieved from MadX
        Throws:
        JMadModelException - if the matching fails
      • saveBeta

        void saveBeta​(java.lang.String name,
                      java.lang.String location,
                      boolean runDummyTwiss)
               throws JMadModelException
        Execute 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 SaveBeta
        location - the location in the sequence where to save the Optical Functions Values
        runDummyTwiss - 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 to

        twiss(TfsResultRequest.createSummaryOnlyRequest()).getSummary()

        Returns:
        the summary part of the actually valid twiss result.
        Throws:
        JMadModelException - if the twiss 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: Range addMisalignments(), addMisalignment())