Conversation
Port the cleed++ sources from develop, gate the build with BUILD_CPP_BINDINGS, and add a small C++ smoke executable. Ensure C headers are C++-safe and document the experimental C++ API.
|
Warning Rate limit exceeded@Liam-Deacon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 24 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (110)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideAdds an experimental C++ wrapper library (cleed++) around existing CLEED C APIs, gated by a new BUILD_CPP_BINDINGS CMake option, wires it into the build/install (including a small smoke executable), and updates several public C headers with extern "C" guards for C++ consumers plus initial Sphinx documentation for the bindings. Class diagram for core chemistry and geometry types in cleed++classDiagram
class BaseElement {
+BaseElement()
+BaseElement(size_t atomicNumber)
+BaseElement(string name)
+BaseElement(char symbol[])
+size_t getAtomicNumber() const
+string getElementName() const
+string getElementSymbol() const
+void setAtomicNumber(size_t Z)
+void setElementName(string name)
+void setElementSymbol(char symbol[])
-size_t atomicNumber
-string name
-char symbol
}
class BasicElement {
<<concrete>>
+enum atomicNumber
+BasicElement()
+BasicElement(unsigned int Z)
+BasicElement(string name)
+bool operator!()
+BasicElement operator=(string id)
+BasicElement operator=(int Z)
+BasicElement operator-(int Z)
+BasicElement operator+(int Z)
+bool operator==(BasicElement other)
+bool operator==(string element)
+bool operator!=(BasicElement other)
+bool operator!=(string element)
+bool operator<(BasicElement other)
+bool operator>(BasicElement other)
+bool operator<=(BasicElement other)
+bool operator>=(BasicElement other)
+int getAtomicNumber() const
+string getName() const
+string getSymbol() const
+BasicElement setAtomicNumber(size_t Z)
+BasicElement setName(string name)
+BasicElement setSymbol(string symbol)
-unsigned int Z
-string name
-string symbol
+static map~string,unsigned int~ NAMES
+static map~string,unsigned int~ SYMBOLS
+static map~string,BasicElement~ ELEMENTS
}
class Element {
<<concrete>>
+Element(int Z,string symbol,string name)
+int getGroup() const
+int getPeriod() const
+char getBlock() const
+int getSeries() const
+double getMolarMass() const
+double getElectronegivity() const
+double getElectronAffinity() const
+double getCovalentRadius() const
+double getAtomicRadius() const
+double getVanDerWaalsRadius() const
+double getBoilingPoint() const
+double getMeltingPoint() const
+double getDensity() const
+string getElectronConfiguration() const
+string getOxidationStates() const
+vector~double~ getIonisationEnergies() const
+string getDescription() const
+Element setGroup(int group)
+Element setGroup(string group)
+Element setPeriod(int period)
+Element setPeriod(string period)
+Element setBlock(int block)
+Element setBlock(char block)
+Element setSeries(int series)
+Element setSeries(string series)
+Element setMolarMass(double mass)
+Element setElectronegativity(double electronegativity)
+Element setElectronAffinity(double electronAffinity)
+Element setCovalentRadius(double covalentRadius)
+Element setAtomicRadius(double atomicRadius)
+Element setVanDerWaalsRadius(double vdwRadius)
+Element setBoilingPoint(double tboil)
+Element setMeltingPoint(double tmelt)
+Element setDensity(double density)
+Element setElectronConfiguration(string config)
+Element setOxidationStates(string oxidationStates)
+Element setIonisationEnergies(vector~double~ ionEnergies)
+Element setDescription(string description)
-int group
-int period
-char block
-int series
-double molarMass
-double electronegativity
-double electronAffinity
-double covalentRadius
-double atomicRadius
-double vdwRadius
-double boilingPoint
-double meltingPoint
-double density
-double relativeAbundance
-string eletronConfig
-string oxidationStates
-vector~double~ ionisationEnergies
-string description
+static map~int,char~ PERIODS
+static vector~char~ BLOCKS
+static map~int,string~ SERIES
+static map~int,tuple~string,string~~ GROUPS
+static map~int,string~ DESCRIPTIONS
}
class Atom {
<<abstract>>
+Atom()
+Atom(double x,double y,double z)
+Atom(vector~double~ pos)
+double getXPosition() const
+double getYPosition() const
+double getZPosition() const
+vector~double~ getPosition() const
+Atom setXPosition(double x_pos)
+Atom setYPosition(double y_pos)
+Atom setZPosition(double z_pos)
+Atom setPosition(vector~double~ pos)
-double x
-double y
-double z
}
class Coordinate {
+coord *pos
+Coordinate()
+Coordinate(double x,double y,double z)
+Coordinate(Coordinate position)
+Coordinate(coord *position)
+Coordinate setX(double x)
+Coordinate setY(double y)
+Coordinate setZ(double z)
+Coordinate setCoordinate(double x,double y,double z)
+Coordinate setCoordinate(Coordinate position)
+Coordinate setCoordinate(coord *position)
+double getMagnitude()
+double getX()
+double getY()
+double getZ()
+coord *get_coord()
+void print(FILE *f)
}
class Basis {
+basis *basis_ptr
+Basis()
+Basis(basis *a)
+Basis(Basis a)
+Basis setA1(Coordinate a1)
+Basis setA1(double a1_x,double a1_y,double a1_z)
+Basis setA2(Coordinate a2)
+Basis setA2(double a2_x,double a2_y,double a2_z)
+Basis setA3(Coordinate a3)
+Basis setA3(double a3_x,double a3_y,double a3_z)
+Basis setBasis(Coordinate a1,Coordinate a2,Coordinate a3)
+Basis setBasis(Basis basis)
+Basis setBasis(Basis *basis)
+Coordinate getA1() const
+Coordinate getA2() const
+Coordinate getA3() const
}
class MillerIndex {
+MillerIndex(double h,double k,double l)
+MillerIndex(miller_hkl *hkl)
+double getMillerH() const
+double getMillerK() const
+double getMillerL() const
+void getMillerIndices(double h,double k,double l) const
+string getMillerIndicesAsString() const
+MillerIndex setMillerH(double h)
+MillerIndex setMillerK(double k)
+MillerIndex setMillerL(double l)
+MillerIndex setMillerIndices(double h,double k,double l)
-double h
-double k
-double l
}
class Model {
}
class BulkModel {
}
class invalidElementException {
+invalidElementException(char *msg)
+~invalidElementException()
+char *what() const
-string err_msg
}
BaseElement <|-- BasicElement
BasicElement <|-- Element
BaseElement <|-- Atom
Element ..|> BasicElement
Atom ..|> BaseElement
BulkModel --|> Model
invalidElementException ..|> std_exception
Class diagram for LEED and crystal modelling types in cleed++classDiagram
class LEED {
+LEED()
+~LEED()
}
class Crystal {
<<wraps leed_crystal>>
+Crystal()
+Crystal(leed_crystal *crystal_ptr)
+Crystal(Crystal crystal)
+~Crystal()
+bool operator==(Crystal other) const
+bool operator!=(Crystal other) const
+bool operator==(leed_crystal *other) const
+bool operator!=(leed_crystal *other) const
+double getRealOpticalPotential() const
+double getImaginaryOpticalPotential() const
+double getTemperature() const
+size_t getNumberOfRotationalSymmetries() const
+vector~double~ getAxisOfRotationalSymmetry() const
+size_t getNumberOfMirrorPlanes() const
+real *getMirrorPlaneGeometryPtr() const
+vector~double~ getMirrorPlaneGeometry() const
+leed_mirror_sym getMirrorSymmetry() const
+real *getAngleAlphaDegreesPtr() const
+vector~double~ getAngleAlphaDegrees() const
+vector~double~ getSubstrateBasisVectors() const
+double getSubstrateUnitCellArea() const
+vector~double~ getSuperstructureBasisVectors() const
+double getSuperstructureRelativeUnitCellArea() const
+size_t getNumberOfLayers() const
+leed_layer *getLayersPtr() const
+vector~leed_layer~ getLayers() const
+double getMinimumInterlayerDistance() const
+size_t getNumberOfAtoms() const
+size_t getNumberOfTypes() const
+vector~string~ getComments() const
+void setRealOpticalPotential(double vr)
+void setImaginaryOpticalPotential(double vi)
+void setTemperature(double temp)
+void setNumberOfRotationalSymmetries(size_t n_rot)
+void setAxisOfRotationalSymmetry(vector~double~ rot_axis)
+void setAxisOfRotationalSymmetry(double *rot_axis,size_t n)
+void setNumberOfMirrorPlanes(size_t n_mir)
+void setMirrorPlaneGeometry(vector~double~ m_plane)
+void setMirrorPlaneGeometry(double *m_plane,size_t n)
+void setMirrorSymmetry(leed_mirror_sym symmetry)
+void setAngleAlphaDegrees(vector~double~ alpha)
+void setAngleAlphaDegrees(double *alpha,size_t n)
+void setSubstrateBasisVectors(vector~double~ a)
+void setSubstrateUnitCellArea(double area)
+void setSuperstructureBasisVectors(vector~double~ b)
+void setSuperstructureRelativeUnitCellArea(double rel_area)
+void setNumberOfLayers(size_t n_layers)
+void setLayers(vector~leed_layer~ layers)
+void setLayers(leed_layer *layers,size_t n_layers)
+void setMinimumInterlayerDistance(double d_min)
+void setNumberOfAtoms(size_t n_atoms)
+void setNumberOfTypes(size_t n_types)
+void setComments(vector~string~ comments)
+void setComments(char **comments,size_t n_comments)
}
class Layer {
<<wraps leed_layer>>
+Layer()
+Layer(leed_layer *layer)
+~Layer()
+bool isPeriodic()
+size_t getLayerNumber()
+size_t getNumberOfAtoms()
+leed_structure getLayerType()
+vector~real~ getA1()
+vector~real~ getA2()
+vector~vector~real~~ getBasis()
+real getRelativeArea()
+vector~vector~real~~ getRegistryShift()
+vector~vector~real~~ getVectorFromLast()
+vector~vector~real~~ getVectorToNext()
+vector~Atom~ getAtomList()
+Layer setPeriodic(bool periodic)
+Layer setLayerNumbers(size_t number)
+Layer setLayerType(leed_structure type)
+Layer setA1(real a1x,real a1y)
+Layer setA2(real a2x,real a2y)
+Layer setRelativeArea(real area)
+Layer setAtoms(vector~Atom~ atomList)
+Layer setAtoms(leed_atom *atoms,size_t n)
+Layer setAtom(leed_atom *atom,int index)
+Layer setAtom(LEEDAtom atom,int index)
}
class LEEDAtom {
<<wraps leed_atom, extends Atom>>
+LEEDAtom()
+LEEDAtom(LEEDAtom other)
+~LEEDAtom()
+LEEDAtom operator=(LEEDAtom other)
+bool operator==(LEEDAtom other) const
+bool operator!=(LEEDAtom other) const
+size_t getLayerNumber()
+leed_structure getStructureType()
+leed_matrix_diag getMatrixType()
+real getDebyeWallerFactor()
+double getXPosition() const
+double getYPosition() const
+double getZPosition() const
+vector~double~ getPosition() const
+LEEDAtom setLayerNumber(size_t number)
+LEEDAtom setMatrixType(leed_matrix_diag type)
+LEEDAtom setStructureType(leed_structure structure)
+LEEDAtom setDebyeWallerFactor(real dwf)
+LEEDAtom setXPosition(double x_pos)
+LEEDAtom setYPosition(double y_pos)
+LEEDAtom setZPosition(double z_pos)
+LEEDAtom setPosition(vector~double~ pos)
}
class PhaseShift {
<<wraps leed_phase>>
+PhaseShift()
+PhaseShift(leed_phase *phsh_ptr)
+PhaseShift(string inputFile)
+~PhaseShift()
+PhaseShift operator+(PhaseShift phsh)
+int getLmax() const
+leed_matrix_diag getMatrixType() const
+real getMaxEnergy() const
+real getMinEnergy() const
+vector~real~ getEnergyList() const
+vector~real~ getPhaseShiftValuesList() const
+vector~real~ getDeltaRList() const
+size_t getNumberOfEnergies() const
+PhaseShift setLmax(int lmax)
+PhaseShift setMatrixType(leed_matrix_diag Type)
+PhaseShift setMaxEnergy(real Emax)
+PhaseShift setMinEnergy(real Emin)
+PhaseShift setInputFile(string filepath)
+PhaseShift setInputFile(char *filepath)
+PhaseShift setData(real *energies_ptr,real *phaseshifts_ptr,size_t n)
+PhaseShift setData(vector~real~ energies,vector~real~ phaseshifts)
+PhaseShift setDeltaR(vector~real~ dr)
+PhaseShift setDeltaR(real dr[4])
+void setDataFromFile()
}
class Pattern {
<<wraps pattern>>
+Pattern()
+Pattern(Pattern other)
+Pattern(pattern *pattern_ptr)
+~Pattern()
+string getTitle()
+size_t getNumberOfDomains()
+double getRadius()
+vector~double~ getBasisVectorA1()
+vector~double~ getBasisVectorA2()
+vector~Matrix2x2~ getSuperStructureMatrices()
+bool isSquare()
+void setTitle(string title)
+void setBasisVectorA1(double x,double y)
+void setBasisVectorA2(double x,double y)
+int setNumberOfDomains(size_t n_dom)
+void setRadius(double radius)
+void setSuperStructureMatrix(Matrix2x2 *mat,size_t domain)
+void setSquare(bool isSquare)
}
Atom <|-- LEEDAtom
Crystal "1" o-- "*" Layer : aggregates
Layer "1" o-- "*" LEEDAtom : contains
Class diagram for RFactor, IV curves, and search wrappers in cleed++classDiagram
class IVCurve {
<<wraps rfac_iv>>
-rfac_iv *iv_ptr
-string comments
+IVCurve()
+IVCurve(rfac_iv iv)
+IVCurve(string ivFilePath)
+IVCurve(IVCurve ivCurve)
+~IVCurve()
+IVCurve operator=(IVCurve other)
+bool operator==(IVCurve other) const
+bool operator!=(IVCurve other) const
+IVCurve setIVData(rfac_iv_data iv_data,size_t n)
+IVCurve setIVData(vector~real~ x,vector~real~ y,vector~real~ deriv2)
+IVCurve sort()
+IVCurve smooth(double vi)
+IVCurve spline()
+IVCurve setInitialEnergy(double e_0)
+IVCurve setLastEnergy(double e_n)
+IVCurve setMaximumIntensity(double maxI)
+void writeIVData(string ivFilePath)
+rfac_iv_data *getRfacIVData() const
+void getIVData(vector~real~ x,vector~real~ y,vector~real~ deriv2) const
+bool isEquiDistant() const
+bool isSorted() const
+bool isSmoothed() const
+bool isSplined() const
+double getInitialEnergy() const
+double getLastEnergy() const
+double getMaximumIntensity() const
+rfac_iv *get_rfac_iv_ptr() const
+void readIVData(string ivFilePath)
}
class IVCurvePair {
-rfac_ivcur *iv_pair
+IVCurvePair(IVCurvePair other)
+IVCurvePair(rfac_ivcur *ivcur_ptr)
+IVCurvePair(IVCurve theory,IVCurve experimental)
+~IVCurvePair()
+double getWeighting() const
+double getEnergyOfFirstAppearance() const
+double getOverlap() const
+int getGroupID() const
+rfac_ivcur *getIVPairPtr() const
+void calculateOverlap()
+IVCurvePair setWeighting(double weight)
+IVCurvePair setSpotID(rfac_spot *spot)
+IVCurvePair setTheoryIVCurve(IVCurve theory)
+IVCurvePair setExperimentalIVCurve(IVCurve experimental)
}
class RFactorArgs {
<<wraps rfac_args>>
-rfac_args c_args
+RFactorArgs(RFactorArgs other)
+RFactorArgs(int argc,char *argv[])
+RFactorArgs(rfac_args *args_ptr)
+RFactorArgs(string ctrFile,string theoryFile,rfactor_type type,double initialEnergyShift,double finalEnergyShift,double energyShiftStep,double vi,bool allGroups,char *ivOutputFile,char *outputFile)
+~RFactorArgs()
+RFactorArgs operator=(RFactorArgs other)
+RFactorArgs operator=(rfac_args *args_ptr)
+string getControlFile() const
+string getTheoryFile() const
+string getOutputFile() const
+string getIVOutputFile() const
+rfactor_type getRFactorType() const
+double getInitialEnergyShift() const
+double getFinalEnergyShift() const
+double getEnergyShiftStep() const
+double getOpticalPotential() const
+bool getAllGroups() const
+void setControlFile(string ctrFile)
+void setTheoryFile(string theoryFile)
+void setOutputFile(string outputFile)
+void setIVOutputFile(string ivOutputFile)
+void setRFactorType(rfactor_type type)
+void setInitialEnergyShift(double dE0)
+void setFinalEnergyShift(double dEf)
+void setEnergyShiftStep(double dEs)
+void setOpticalPotential(double vi)
+void setAllGroups(bool allGroups)
}
class RFactor {
-vector~IVCurvePair~ iv_datasets
-RFactorArgs args
-double rfactor
-double relativeError
-double iRatio
-double energyShift
-double energyRange
+RFactor(string control_filepath,string theory_filepath)
+~RFactor()
+bool operator==(RFactor other) const
+bool operator!=(RFactor other) const
+void calculateRFactor()
+void updateIVs(string control_filepath,string theory_filepath)
+void updateIVs(vector~IVCurvePair~ ivs)
+double getRFactor() const
+double getRR() const
+double getTotalEnergyRange() const
+double getTheoryToExperimentalIntegralRatio() const
+double getMinimumEnergyShift() const
}
class SearchAtom {
<<wraps search_atom, extends Atom>>
+SearchAtom()
+SearchAtom(SearchAtom other)
+~SearchAtom()
+int getType() const
+size_t getNumberOfEquivalentAtoms() const
+size_t getReferenceToSymmetryEquivalentAtom() const
+string getAtomName() const
+double getMinimumRadius() const
+double getDeltaR() const
+double getXPosition() const
+double getYPosition() const
+double getZPosition() const
+vector~double~ getPosition() const
+vector~double~ getXShifts()
+vector~double~ getYShifts()
+vector~double~ getZShifts()
+vector~double~ getDeltaRShifts()
+void setType(int type)
+void setNumberOfEquivelentAtoms(size_t ref)
+void setReferenceToSymmetryEquivalentAtom(size_t n_ref)
+void setAtomName(char *name)
+void setAtomName(string name)
+void setMinimumRadius(double r_min)
+void setXPosition(double x_pos)
+void setYPosition(double y_pos)
+void setZPosition(double z_pos)
+void setPosition(vector~double~ pos)
}
class Search {
-search c_search
-RFactor *rfactor_ptr
-LEED *leed_ptr
-string theory_filepath
-string control_filepath
+Search(string control_filepath,string theory_filepath,search_method driver)
+~Search()
+size_t getNumberOfIndependentParameters() const
+size_t getNumberOfGeometricalParameters() const
+double getMinimumX() const
+double getMinimumY() const
+double getMinimumZ() const
+double getMaximumX() const
+double getMaximumY() const
+double getMaximumZ() const
+vector~double~ getBasis() const
+bool isAngleSearch() const
+size_t getNumberOfThetaParameters() const
+size_t getNumberOfPhiParameters() const
+double getInitialThetaValue() const
+double getInitialPhiValue() const
+bool isZOnlySearch() const
+size_t getNumberOfRotationalSymmetries() const
+vector~double~ getRotationalAxis() const
+vector~double~ getMirrorPlanePoint() const
+vector~double~ getMirrorPlaneDirection() const
+string getRFactorType() const
+double getRFactorShiftRange() const
+RFactor *getRFactor() const
+void setNumberOfIndependentParameters(size_t n_par)
+void setNumberOfGeometricalParameters(size_t n_geo)
+void setMinimumX(double x_min)
+void setMinimumY(double y_min)
+void setMinimumZ(double z_min)
+void setMaximumX(double x_max)
+void setMaximumY(double y_max)
+void setMaximumZ(double z_max)
+void setBasis(vector~double~ basis)
+void setAngleSearch(bool angle)
+void setNumberOfThetaParameters(size_t n_theta)
+void setNumberOfPhiParameters(size_t n_phi)
+void setInitialThetaValue(double theta_0)
+void setInitialPhiValue(double phi_0)
+void setZOnlySearch(bool z_only)
+void setNumberOfRotationalSymmetries(size_t n_rot)
+void setRotationalAxis(vector~double~ rot_axis)
+void setMirrorPlanePoint(vector~double~ mir_point)
+void setMirrorPlaneDirection(vector~double~ mir_dir)
+void setRFactorType(string type)
+void setRFactorType(char *type)
+void setRFactorShiftRange(double range)
+void setRFactor(RFactor rfac)
+void setTheoryFilePath(string theory_filepath)
+void setControlFilePath(string control_filepath)
+void startSearch()
+void stopSearch()
+void resumeSearch()
}
class AoIRFactor {
<<specialised RFactor (angle of incidence)>>
}
Atom <|-- SearchAtom
IVCurvePair "1" o-- "1" IVCurve : theory
IVCurvePair "1" o-- "1" IVCurve : experimental
RFactor "1" o-- "*" IVCurvePair : uses
RFactor "1" o-- "1" RFactorArgs : configuredBy
Search "1" o-- "1" RFactor : owns
AoIRFactor --|> RFactor
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Clarifications for #48:
|
Codacy's Analysis Summary100 new issues (≤ 0 issue) Review Pull Request in Codacy →
|
There was a problem hiding this comment.
Sorry @Liam-Deacon, your pull request is larger than the review limit of 150000 diff characters
|




Problem
Issue #48 requests bringing the cleed++ C++ library from develop into master, adding a build toggle, and ensuring C/C++ interoperability for public headers.
Solution
src/cleed++from develop and gate it withBUILD_CPP_BINDINGS.include/cleed++and build a smallcleedpp_smokeexecutable linked against both the C and C++ libraries.extern "C"guards to public C headers that were missing them.Testing
Follow-ups
*.pri,.project,.cproject,.settings).Summary by Sourcery
Add an optional experimental C++ bindings library and ensure C headers are usable from C++.
New Features:
Enhancements:
Documentation: