1 // ****************************************************************************** 2 // 3 // Title: Force Field X. 4 // Description: Force Field X - Software for Molecular Biophysics. 5 // Copyright: Copyright (c) Michael J. Schnieders 2001-2025. 6 // 7 // This file is part of Force Field X. 8 // 9 // Force Field X is free software; you can redistribute it and/or modify it 10 // under the terms of the GNU General Public License version 3 as published by 11 // the Free Software Foundation. 12 // 13 // Force Field X is distributed in the hope that it will be useful, but WITHOUT 14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 // details. 17 // 18 // You should have received a copy of the GNU General Public License along with 19 // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple 20 // Place, Suite 330, Boston, MA 02111-1307 USA 21 // 22 // Linking this library statically or dynamically with other modules is making a 23 // combined work based on this library. Thus, the terms and conditions of the 24 // GNU General Public License cover the whole combination. 25 // 26 // As a special exception, the copyright holders of this library give you 27 // permission to link this library with independent modules to produce an 28 // executable, regardless of the license terms of these independent modules, and 29 // to copy and distribute the resulting executable under terms of your choice, 30 // provided that you also meet, for each linked independent module, the terms 31 // and conditions of the license of that module. An independent module is a 32 // module which is not derived from or based on this library. If you modify this 33 // library, you may extend this exception to your version of the library, but 34 // you are not obligated to do so. If you do not wish to do so, delete this 35 // exception statement from your version. 36 // 37 // ****************************************************************************** 38 package ffx.xray; 39 40 import static ffx.numerics.math.DoubleMath.sub; 41 42 import ffx.numerics.math.DoubleMath; 43 import ffx.potential.bonded.Atom; 44 import ffx.xray.RefinementMinimize.RefinementMode; 45 46 /** 47 * SolventBinaryFormFactor class. 48 * 49 * @author Timothy D. Fenn 50 * @since 1.0 51 */ 52 public final class SolventBinaryFormFactor implements FormFactor { 53 54 private final double[] xyz = new double[3]; 55 private final double[] dxyz = new double[3]; 56 private final double probeRad; 57 58 /** 59 * Constructor for SolventBinaryFormFactor. 60 * 61 * @param atom a {@link ffx.potential.bonded.Atom} object. 62 * @param probeRad a double. 63 */ 64 public SolventBinaryFormFactor(Atom atom, double probeRad) { 65 this(atom, probeRad, atom.getXYZ(null)); 66 } 67 68 /** 69 * Constructor for SolventBinaryFormFactor. 70 * 71 * @param atom a {@link ffx.potential.bonded.Atom} object. 72 * @param probeRad a double. 73 * @param xyz an array of double. 74 */ 75 public SolventBinaryFormFactor(Atom atom, double probeRad, double[] xyz) { 76 this.probeRad = probeRad; 77 78 update(xyz); 79 } 80 81 /** {@inheritDoc} */ 82 @Override 83 public double rho(double f, double lambda, double[] xyz) { 84 sub(this.xyz, xyz, dxyz); 85 return rho(f, lambda, DoubleMath.length(dxyz)); 86 } 87 88 /** 89 * rho 90 * 91 * @param f a double. 92 * @param lambda a double. 93 * @param ri a double. 94 * @return a double. 95 */ 96 public double rho(double f, double lambda, double ri) { 97 if (ri <= probeRad) { 98 return 0.0; 99 } else { 100 return f; 101 } 102 } 103 104 /** 105 * Derivatives are zero or infinite for the binary model. 106 * 107 * <p>{@inheritDoc} 108 */ 109 @Override 110 public void rhoGrad(double[] xyz, double dfc, RefinementMode refinementmode) {} 111 112 /** {@inheritDoc} */ 113 @Override 114 public void update(double[] xyz) { 115 update(xyz, 0.0); 116 } 117 118 /** {@inheritDoc} */ 119 @Override 120 public void update(double[] xyz, double badd) { 121 this.xyz[0] = xyz[0]; 122 this.xyz[1] = xyz[1]; 123 this.xyz[2] = xyz[2]; 124 } 125 }