Each macro-cycle of a weight trial used to start a fresh Ceres solve: the L-BFGS memory was dropped every 10 (positions) or 5 (B) iterations and every cycle began with a steepest-descent step. RefinementMinimiser keeps one memory for the positions and one for the B factors across a trial's macro-cycles (the target's scale and likelihood parameters are refitted in between, which the memory tolerates), with a backtracking Armijo line search and Oren-Shanno scaling of a diagonal initial inverse Hessian. The diagonal: for B, the X-ray curvature per atom - the likelihood's curvature in |F_model| per resolution shell against the atom's (s^2/4)^2 f^2 exp(-B s^2/2), calibrated once per trial by a central-difference probe along a random direction - plus the B restraints'. For the positions none: tried with the restraints' Gauss-Newton diagonal (bonds and angles, ~1e4 per axis against the X-ray's ~1e2) it slowed the minimiser, since that stiffness is in directions that move bonded atoms together. Same budget (10 cycles x 10 + 5 iterations, same ladder), median R-free (REFMAC 0-cycle scorer) from the refinement battery's MD starts, base -> this: 5f6m (8 starts) 0.250 -> 0.210, 8dqb (8) 0.387 -> 0.345, 7arr 0.383 -> 0.356, 11if 0.325 -> 0.295, 5reo 0.316 -> 0.326 (CA RMSD 0.48 -> 0.43), 7d98 0.416 -> 0.393; REFMAC converged: 0.168 / 0.284 / 0.311 / 0.251 / 0.261 / 0.361. Deposited models (14 parity sets): R-work lower, R-free +0.0035 on average (their free sets were fitted to; the minimiser now moves the bottom rung further). Time unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit dfba4c1bd3c9345f31b64fd1cadc805810960825)
102 lines
6.6 KiB
CMake
102 lines
6.6 KiB
CMake
ADD_LIBRARY(JFJochStructureRefinement STATIC
|
|
ModelFFT.cpp ModelFFT.h
|
|
ModelGrid.cpp ModelGrid.h
|
|
ModelScaling.cpp ModelScaling.h
|
|
MolecularReplacement.cpp MolecularReplacement.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:MolecularReplacementGPU.cu> MolecularReplacementGPU.h
|
|
ModelValidation.cpp ModelValidation.h
|
|
RugnuxModel.h
|
|
RigidBodyRefine.cpp RigidBodyRefine.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:RigidBodyGPU.cpp>
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:RigidBodyGPU.cu>
|
|
RigidBodyGPU.h RigidBodyGPUEngine.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:ModelDensityGPU.cu> ModelDensityGPU.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:ModelMaskGPU.cu> ModelMaskGPU.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:ModelStructureFactorsGPU.cpp>
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:ModelStructureFactorsGPU.cu>
|
|
ModelStructureFactorsGPU.h ModelStructureFactorsGPUEngine.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:ModelScaleGPU.cu> ModelScaleGPU.h
|
|
SigmaA.cpp SigmaA.h
|
|
MonomerLibrary.cpp MonomerLibrary.h
|
|
RefinementMath.h RefinementMinimiser.h
|
|
RefinementRestraints.cpp RefinementRestraints.h
|
|
RefinementXray.cpp RefinementXray.h
|
|
Refinement.cpp Refinement.h
|
|
DensityBlobs.cpp DensityBlobs.h
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:RefinementGPU.cpp>
|
|
$<$<BOOL:${JFJOCH_CUDA_AVAILABLE}>:RefinementGPU.cu>
|
|
RefinementGPU.h RefinementGPUEngine.h
|
|
${CMAKE_CURRENT_BINARY_DIR}/MonomerLibraryData.cpp)
|
|
|
|
# The subset of the CCP4 Monomer Library that refinement restrains with (monomers/, chosen by
|
|
# monomers/update_monomers.py), carried in the binary so that nothing is read from disk: every .cif of the
|
|
# directory as a string, cut into pieces of at most 12000 characters - under the 16380 a single literal may
|
|
# hold with MSVC - which MonomerLibrary.cpp joins again. A .cif added or edited re-runs the configure.
|
|
FILE(GLOB MONOMER_CIFS ${CMAKE_CURRENT_SOURCE_DIR}/monomers/*.cif)
|
|
SET_PROPERTY(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${MONOMER_CIFS} ${CMAKE_CURRENT_SOURCE_DIR}/monomers)
|
|
SET(monomer_source "// Generated from image_analysis/structure_refinement/monomers by its CMakeLists.txt - do not edit.\n")
|
|
STRING(APPEND monomer_source "#include \"MonomerLibrary.h\"\n\n")
|
|
SET(monomer_table "")
|
|
SET(monomer_count 0)
|
|
FOREACH(cif ${MONOMER_CIFS})
|
|
GET_FILENAME_COMPONENT(cif_name ${cif} NAME)
|
|
FILE(READ ${cif} text)
|
|
STRING(LENGTH "${text}" text_length)
|
|
SET(pieces "")
|
|
SET(n_pieces 0)
|
|
SET(offset 0)
|
|
WHILE(offset LESS text_length)
|
|
STRING(SUBSTRING "${text}" ${offset} 12000 piece)
|
|
STRING(APPEND pieces "R\"MONLIB(${piece})MONLIB\",\n")
|
|
MATH(EXPR offset "${offset} + 12000")
|
|
MATH(EXPR n_pieces "${n_pieces} + 1")
|
|
ENDWHILE()
|
|
STRING(APPEND monomer_source "static const char *const file_${monomer_count}[] = {\n${pieces}};\n")
|
|
STRING(APPEND monomer_table " {\"${cif_name}\", file_${monomer_count}, ${n_pieces}},\n")
|
|
MATH(EXPR monomer_count "${monomer_count} + 1")
|
|
ENDFOREACH()
|
|
STRING(APPEND monomer_source "\nextern const EmbeddedMonomerFile embedded_monomer_files[] = {\n${monomer_table}};\n")
|
|
STRING(APPEND monomer_source "extern const size_t embedded_monomer_file_count = ${monomer_count};\n")
|
|
# Written only when it changed, so a configure does not rebuild the library.
|
|
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/MonomerLibraryData.cpp.tmp "${monomer_source}")
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_BINARY_DIR}/MonomerLibraryData.cpp.tmp
|
|
${CMAKE_CURRENT_BINARY_DIR}/MonomerLibraryData.cpp COPYONLY)
|
|
TARGET_INCLUDE_DIRECTORIES(JFJochStructureRefinement PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# JFJochIndexing for CUDAMemHelpers.h and, under CUDA, to put cuFFT (RigidBodyGPU.cu) after these
|
|
# objects on the link line.
|
|
TARGET_LINK_LIBRARIES(JFJochStructureRefinement JFJochScaleMerge JFJochIndexing JFJochCommon gemmi fftw3f)
|
|
|
|
IF (APPLE)
|
|
# The rotation function on the Apple GPU (MolecularReplacementMetal.h). Its kernel is compiled when it is first
|
|
# used, from source carried in the binary, as image_analysis/bragg_integration does: the .metal file copied into
|
|
# a generated .cpp here; editing it re-runs the configure.
|
|
FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/MolecularReplacementMetal.metal text)
|
|
SET_PROPERTY(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MolecularReplacementMetal.metal)
|
|
# Written only when it changed, so a configure does not rebuild the library.
|
|
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/MolecularReplacementMetalSource.cpp.tmp
|
|
"// Generated from image_analysis/structure_refinement by its CMakeLists.txt - do not edit.\n"
|
|
"extern const char *const mr_metal_source;\n"
|
|
"const char *const mr_metal_source = R\"MR_METAL(\n${text})MR_METAL\";\n")
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_BINARY_DIR}/MolecularReplacementMetalSource.cpp.tmp
|
|
${CMAKE_CURRENT_BINARY_DIR}/MolecularReplacementMetalSource.cpp COPYONLY)
|
|
TARGET_SOURCES(JFJochStructureRefinement PRIVATE MolecularReplacementMetal.mm MolecularReplacementMetal.h
|
|
MolecularReplacementMetal.metal ${CMAKE_CURRENT_BINARY_DIR}/MolecularReplacementMetalSource.cpp)
|
|
SET_SOURCE_FILES_PROPERTIES(MolecularReplacementMetal.mm PROPERTIES COMPILE_OPTIONS -fobjc-arc)
|
|
SET_SOURCE_FILES_PROPERTIES(MolecularReplacementMetal.metal PROPERTIES HEADER_FILE_ONLY ON)
|
|
# The model density's gather (ModelDensityMetal.h), carried in the same way.
|
|
FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/ModelDensityMetal.metal text)
|
|
SET_PROPERTY(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ModelDensityMetal.metal)
|
|
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModelDensityMetalSource.cpp.tmp
|
|
"// Generated from image_analysis/structure_refinement by its CMakeLists.txt - do not edit.\n"
|
|
"extern const char *const model_density_metal_source;\n"
|
|
"const char *const model_density_metal_source = R\"DENSITY_METAL(\n${text})DENSITY_METAL\";\n")
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_BINARY_DIR}/ModelDensityMetalSource.cpp.tmp
|
|
${CMAKE_CURRENT_BINARY_DIR}/ModelDensityMetalSource.cpp COPYONLY)
|
|
TARGET_SOURCES(JFJochStructureRefinement PRIVATE ModelDensityMetal.mm ModelDensityMetal.h
|
|
ModelDensityMetal.metal ${CMAKE_CURRENT_BINARY_DIR}/ModelDensityMetalSource.cpp)
|
|
SET_SOURCE_FILES_PROPERTIES(ModelDensityMetal.mm PROPERTIES COMPILE_OPTIONS -fobjc-arc)
|
|
SET_SOURCE_FILES_PROPERTIES(ModelDensityMetal.metal PROPERTIES HEADER_FILE_ONLY ON)
|
|
TARGET_LINK_LIBRARIES(JFJochStructureRefinement "-framework Metal" "-framework Foundation")
|
|
ENDIF()
|