@@ -0,0 +1,2710 @@
+/*%0D%0A * Copyright (C) 2018 Satomichi Nishihara%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *     http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0A%0D%0Apackage burai.input.correcter;%0D%0A%0D%0Aimport burai.atoms.element.ElementUtil;%0D%0Aimport burai.input.QEInput;%0D%0Aimport burai.input.card.QEAtomicSpecies;%0D%0Aimport burai.pseudo.PseudoData;%0D%0Aimport burai.pseudo.PseudoPotential;%0D%0A%0D%0Apublic class SpinCorrector %7B%0D%0A%0D%0A    public enum SpinType %7B%0D%0A        NON_POLARIZED,%0D%0A        COLINEAR,%0D%0A        NON_COLINEAR;%0D%0A    %7D%0D%0A%0D%0A    private QEInput input;%0D%0A%0D%0A    private QEAtomicSpecies cardSpecies;%0D%0A%0D%0A    public SpinCorrector(QEInput input) %7B%0D%0A        if (input == null) %7B%0D%0A            throw new IllegalArgumentException(%22input is null.%22);%0D%0A        %7D%0D%0A%0D%0A        this.input = input;%0D%0A%0D%0A        this.cardSpecies = this.input.getCard(QEAtomicSpecies.class);%0D%0A    %7D%0D%0A%0D%0A    public boolean isAvailable() %7B%0D%0A        if (this.cardSpecies == null %7C%7C this.cardSpecies.numSpecies() %3C 1) %7B%0D%0A            return false;%0D%0A        %7D%0D%0A%0D%0A        return true;%0D%0A    %7D%0D%0A%0D%0A    public SpinType getSpinType() %7B%0D%0A        if (this.cardSpecies == null) %7B%0D%0A            return SpinType.NON_POLARIZED;%0D%0A        %7D%0D%0A%0D%0A        int numSpecies = this.cardSpecies.numSpecies();%0D%0A%0D%0A        boolean hasRelative = false;%0D%0A        boolean hasTransMetal = false;%0D%0A%0D%0A        for (int i = 0; i %3C numSpecies; i++) %7B%0D%0A            PseudoPotential pseudoPot = this.cardSpecies.getPseudoPotential(i);%0D%0A            if (pseudoPot != null) %7B%0D%0A                int relative = pseudoPot.getData().getRelativistic();%0D%0A                if (relative == PseudoData.RELATIVISTIC_FULL) %7B%0D%0A                    hasRelative = true;%0D%0A                %7D%0D%0A            %7D%0D%0A%0D%0A            String label = this.cardSpecies.getLabel(i);%0D%0A            label = label == null ? null : label.trim();%0D%0A            if (label != null && !label.isEmpty()) %7B%0D%0A                if (ElementUtil.isTransitionMetal(label)) %7B%0D%0A                    hasTransMetal = true;%0D%0A                %7D%0D%0A            %7D%0D%0A        %7D%0D%0A%0D%0A        if (hasRelative) %7B%0D%0A            return SpinType.NON_COLINEAR;%0D%0A%0D%0A        %7D else if (hasTransMetal) %7B%0D%0A            return SpinType.COLINEAR;%0D%0A%0D%0A        %7D else %7B%0D%0A            return SpinType.NON_POLARIZED;%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

create SpinCorrector