/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.species;

import etomica.atom.AtomType;
import etomica.config.ConformationChainZigZag2;
import etomica.space.Space;
import etomica.space.Vector;
import etomica.space3d.Space3D;

public class SpeciesAlkane {

    // parameters for TraPPE
    public static final double nominalBondL = 1.54;
    public static final double nominalBondTheta = Math.PI * 114 / 180;

    public static SpeciesGeneral create(int numCarbons) {
        return create(numCarbons, AtomType.simple("CH3", 15), AtomType.simple("CH2", 14));
    }

    public static SpeciesGeneral create(int numCarbons, AtomType ch3Type, AtomType ch2Type) {
        return create(numCarbons, ch3Type, ch2Type, nominalBondL, nominalBondTheta);
    }

    public static SpeciesGeneral create(int numCarbons, AtomType ch3Type, AtomType ch2Type, double bondL, double bondTheta) {
        Space space = Space3D.getInstance();
        ConformationChainZigZag2 conf = new ConformationChainZigZag2(
                space,
                Vector.of(bondL, 0, 0),
                Vector.of(-bondL * Math.cos(bondTheta), bondL * Math.sin(bondTheta), 0)
        );
        return new SpeciesBuilder(Space3D.getInstance())
                .addCount(ch3Type, 1)
                .addCount(ch2Type, Math.max(numCarbons - 2, 0))
                .addCount(ch3Type, Math.min(1, numCarbons-1))
                .withConformation(conf)
                .build();
    }
}

@@ -307,36 +307,8 @@
 g2;%0A
-import etomica.space.Space;%0A
 impo
@@ -1028,53 +1028,245 @@
     
-Space space = Space3D.getInstance(
+return makeBuilder(numCarbons, ch3Type, ch2Type, bondL, bondTheta).build();%0A    %7D%0A%0A    public static ConformationChainZigZag2 makeConformation() %7B%0A        return makeConformation(nominalBondL, nominalBondTheta
 );%0A    
+%7D%0A%0A
     
+public static 
 Conf
@@ -1290,14 +1290,73 @@
 ag2 
-conf =
+makeConformation(double bondL, double bondTheta) %7B%0A        return
  new
@@ -1398,21 +1398,37 @@
         
-s
+S
 pace
+3D.getInstance()
 ,%0A      
@@ -1560,16 +1560,592 @@
      );%0A
+    %7D%0A%0A    public static SpeciesBuilder makeBuilder(int numCarbons) %7B%0A        return makeBuilder(numCarbons, AtomType.simple(%22CH3%22, 15), AtomType.simple(%22CH2%22, 14));%0A    %7D%0A%0A    public static SpeciesBuilder makeBuilder(int numCarbons, AtomType ch3Type, AtomType ch2Type) %7B%0A        return makeBuilder(numCarbons, ch3Type, ch2Type, nominalBondL, nominalBondTheta);%0A    %7D%0A%0A    public static SpeciesBuilder makeBuilder(int numCarbons, AtomType ch3Type, AtomType ch2Type, double bondL, double bondTheta) %7B%0A        ConformationChainZigZag2 conf = makeConformation(bondL, bondTheta);%0A
         
@@ -2400,33 +2400,8 @@
 onf)
-%0A                .build()
 ;%0A  

allow builder to be returned