<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> I manage to find how position and ADP constraints are handled <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">by constraint objects featuring methods to return the independent <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">variables and the gradient with respect to them. Then cctbx/cctbx/</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">examples/structure_factor_derivatives_4.py shows how those features <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">can be used. Would Hydrogen geometry constraint be best handled by <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">mimicking those special positions constraint?</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I am not sure. The handling of hydrogens seems more complicated than</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">dealing with the constraints due to symmetry. I just had a quick look</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">at the SHELX manual. I see many special cases.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>Aplenty indeed. Right. Let me precise my question then. The two classes dealing with position and ADP symmetry constraints feature the same methods:</DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">- n_independent_params</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">- independent_params</SPAN></FONT></DIV><DIV>- all_params</DIV><DIV>- independent_gradients</DIV><DIV>- independent_curvatures</DIV><DIV>- gradient_sum_matrix</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I was trying to figure out whether this interface would be sufficient and/or necessary for the Hydrogen geometry constraints. I am not quite sure I understand what is gradient_sum_matrix exactly in fact. </DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If I had a chance to work on this, I'd start with a Python script</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">emulating some of the cases handled by SHELX, refining a few small</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">structures. After getting a few concrete examples to work, I'd try to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">generalize the procedures for handling the special cases. I'd switch to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">C++ only after having fully conquered the math and the bookkeeping in</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Python, and being sure about the final interfaces.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>It is the philosophy of the cctbx, isn't it? You have constructed the cctbx so as to use it as Python library, relegating C++ to some sort of assembly language for efficiency. The lack of abstraction in the C++ code of the cctbx (hardly any inheritance, no advanced genericity) would require wrapping a lot of the cctbx classes behind proxies inheriting from abstract types. A typical example for me are those classes dealing with position constraints and ADP constraints. They are unrelated in C++, cctbx::sgtbx::<FONT class="Apple-style-span" face="Monaco" size="3"><FONT class="Apple-style-span" color="#000000" face="Lucida Sans"><SPAN class="Apple-style-span" style="background-color: transparent;">site_constraints</SPAN></FONT><SPAN class="Apple-style-span" style="font-size: 11px;"> </SPAN><FONT class="Apple-style-span" color="#000000" face="Lucida Sans"><SPAN class="Apple-style-span" style="background-color: transparent;">and cctbx::sgtbx::tensor_rank_2::constraints, although they have both have the same member functions listed above. Of course, from Python, it does not matter, thanks to duck typing: if two objects answer the same method calls, then they are by all practical means of the same type.</SPAN></FONT></FONT></DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">To implement the core refinement, I'd copy and modify</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">cctbx/cctbx/xray/minimization.py. See also</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">phenix/phenix/substructure/hyss/minimization.py, which you can find</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">in the CCI Apps bundle (<A href="http://phenix-online.org/download/cci_apps/">http://phenix-online.org/download/cci_apps/</A>).</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I have already started to study the former. Thanks for pointing out the latter. </DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hope this helps. As you can tell, I am not an expert in constrained</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">hydrogen refinement, but I'm very interested in seeing such algorithms</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">in the cctbx (we'd probably want to use them in phenix.refine). Let me</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">know if you feel I can do something to help out.</DIV></BLOCKQUOTE></DIV><BR><DIV>Our group would be more than happy to contribute them to the cctbx since we absolutely need them for our project. </DIV><DIV>Cheerio,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Luc</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>