Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Indentation and Update Compute Function #12

Closed
wants to merge 3 commits into from
Closed

Fix Indentation and Update Compute Function #12

wants to merge 3 commits into from

Conversation

erickfaria
Copy link
Contributor

Hello,

I have made some updates to the code which should resolve the issues we were experiencing. Here are the details:

  1. Indentation: I have corrected the indentation in our codebase to ensure it adheres to our style guidelines.

  2. Update to Compute Function: I have made a significant change to the compute function. The original function was as follows:

def compute(self):
    y1 = odeint(self.dCdt, self.C0, t=self.t, rtol=0.01, atol=0.01)
    return pd.DataFrame(y1, columns=self.ks_pulls)

In the original function, the odeint function was called without passing the necessary arguments (self.input_carbon, self.farmyard_manure, self.DR). I have updated the function to include these arguments. Here is the updated function:

def compute(self):
    y1 = odeint(self.dCdt, self.C0, t=self.t, args=(self.input_carbon, self.farmyard_manure, self.DR), rtol=0.01, atol=0.01)
    return pd.DataFrame(y1, columns=self.ks_pulls)

These changes should eliminate the errors we were encountering. I have tested the updates on my end, and everything is functioning as expected.

Please review these changes and let me know if you have any questions or feedback.

@mishagrol
Copy link
Owner

@erickfaria I think we should update this function to use np.array for carbon and manure input\

def get_input_flux(
        self,
        input_carbon: Union[float, np.ndarray],
        farmyard_manure: Union[float, np.ndarray] = 0,
        DR: Union[float, np.ndarray] = 1.44,
    ) -> np.ndarray:
        """
            Get amount of litter inputs

        Args:
            input_carbon (float): A scalar or np.array
                                the amount of litter inputs by time. Defaults to 1.7.
            farmyard_manure (float, optional): A scalar or np.array object specifying the amount
                                                of Farm Yard Manure inputs by time.
                                                Defaults to 0.
            DR (float, optional): A scalar representing the ratio of decomposable plant material
                                to resistant plant material (DPM/RPM). Defaults to 1.44.

        Returns:
            np.ndarray: input_DPM, input_RPM, input_BIO, input_HUM, input_IOM
        """

        gamma = DR / (1 + DR)
        input_DPM = input_carbon * gamma + (farmyard_manure * 0.49)
        input_DPM = np.sum(input_DPM)
        input_RPM = input_carbon * (1 - gamma) + (farmyard_manure * 0.49)
        input_RPM = np.sum(input_RPM)
        input_BIO = 0
        input_HUM = farmyard_manure * 0.02
        input_RPM = np.sum(input_HUM)
        input_IOM = 0
        return np.array(
            [
                input_DPM,
                input_RPM,
                input_BIO,
                input_HUM,
                input_IOM,
            ]
        )


@erickfaria
Copy link
Contributor Author

Hello @mishagrol ok, I will work on it. I just need more time, I'm kind of busy this days.

@mishagrol
Copy link
Owner

@erickfaria

Hello @mishagrol ok, I will work on it. I just need more time, I'm kind of busy this days.

Thank you! I have fixed these problems and added some new functions, according to request from #9

@erickfaria
Copy link
Contributor Author

@erickfaria

Hello @mishagrol ok, I will work on it. I just need more time, I'm kind of busy this days.

Thank you! I have fixed these problems and added some new functions, according to request from #9

Nice, thank you. I will close this MR

@erickfaria erickfaria closed this Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants