Dear Zohreh, I think, you should describe precisely what you want, rather than referring to previous correspondence. Someone out there (likely not me) might have a solution to what you need - but cannot be bothered to read through you previous correspondence.
1. *Parameter names should be made in a dynamic way*. what exactly do you mean by this? Better give an example of what you would like to do. 2. *how using for loop in string can be simultaneously handled.* I have no idea, what your question is - and I am afraid, not many people understand. Better give an example of what you want to do. Peter On Fri 26. Aug 2022 at 04:42 Zohreh Karimzadeh <z.karimza...@gmail.com> wrote: > As can be seen in the former script, parameter names should be made in a > dynamic way. > I am wondering how using for loop in string can be simultaneously > handled. > Regards, > Zohreh Karimzadeh > *https://www.researchgate.net/profile/Zohreh-Karimzadeh* > <https://www.researchgate.net/profile/Zohreh-Karimzadeh> > Skype Name 49a52224a8b6b38b > Twitter Account @zohrehkarimzad1 > z.karimza...@gmail.com > +989102116325 > ((((((((((((((((Value Water))))))))))))))) > > > On Wed, Aug 24, 2022 at 9:32 PM gu...@uwosh.edu <gu...@uwosh.edu> wrote: > >> Zohreh, >> >> The code snippets you have provided do not suggest you are doing anything >> that requires sympy. So, I am confused. It looks like you need a function >> that generates a string of the summations in your expression, when passed >> species. I think there is a fixed number of parameters for each species. >> You are probably better off building the string for your expressions >> without involving sympy. I am thinking something like this to define part >> of your fit function: >> >> >> def term(species_name): >> >> return(species_name+'_param1*conc_'+species_name+'+'+species_name+'_param2*np.sqrt(conc_'+species_name+')') >> Then >> term('Cl') >> returns >> 'Cl_param1*conc_Cl+Cl_param2*np.sqrt(conc_Cl)' >> >> Then build your overall expression from these pieces. Then do a fit with >> initial guesses for all the parameters. >> >> That's how I would do it unless I am manipulating the expressions using >> sympy first. >> >> Jonathan >> On Wednesday, August 24, 2022 at 11:11:58 AM UTC-5 z.kari...@gmail.com >> wrote: >> >>> I should extract the required model for each system of chemicals and do >>> a least squre for derived model and parameters to find the parameters for >>> each chemical systems. >>> >>> >>> Zohreh Karimzadeh >>> >>> Contact me on >>> +989102116325 <+98%20910%20211%206325> >>> and at >>> z.kari...@gmail.com >>> 🌧️🌍🌱 >>> >>> On Wed, 24 Aug 2022, 19:33 gu...@uwosh.edu, <gu...@uwosh.edu> wrote: >>> >>>> Zohreh, >>>> >>>> I pulled the paper. I see no reason you need to use SymPy to do the >>>> numerical fitting. I would approach this by inputting the species in a >>>> dictionary or list and then use that to call functions that generate the >>>> computed value for each term/sum. Are you trying to keep track of the >>>> complete symbolic expression or do a numerical calculation? >>>> >>>> If you are using chemical symbols or reactions, are you taking >>>> advantage of ChemPy? >>>> >>>> Jonathan >>>> On Tuesday, August 23, 2022 at 12:01:02 AM UTC-5 z.kari...@gmail.com >>>> wrote: >>>> >>>>> As following, I should generate each parameters dynamically (for 20-30 >>>>> terms): >>>>> >>>>> term_vnca = 0 >>>>> for k in anion: >>>>> for j in cation: >>>>> for i in neutral: >>>>> term_vnca += term_vncX - 4 * 3 * sp.symbols(f'X{str(k)}') * >>>>> sp.symbols('X{0}'.format(str(i))) \ >>>>> ** 2 * sp.symbols(f'V{str(i)}{str(j)}{str(k)}') >>>>> lnfXs = term_wnca + term_unca + term_vnca + termx_w_solvent1 + >>>>> termx_w_solvent2 >>>>> >>>>> Zohreh Karimzadeh >>>>> *https://www.researchgate.net/profile/Zohreh-Karimzadeh* >>>>> <https://www.researchgate.net/profile/Zohreh-Karimzadeh> >>>>> Skype Name 49a52224a8b6b38b >>>>> Twitter Account @zohrehkarimzad1 >>>>> z.kari...@gmail.com >>>>> +989102116325 <+98%20910%20211%206325> >>>>> >>>>> ((((((((((((((((Value Water))))))))))))))) >>>>> >>>>> >>>>> On Tue, Aug 23, 2022 at 9:26 AM Zohreh Karimzadeh <z.kari...@gmail.com> >>>>> wrote: >>>>> >>>>>> Not these model and parameters, My model is very complicated wit >>>>>> large number of parameters: >>>>>> [image: image.png] >>>>>> As a very simple example I raise this question. >>>>>> Zohreh Karimzadeh >>>>>> >>>>>> Contact me on >>>>>> +989102116325 <+98%20910%20211%206325> >>>>>> and at >>>>>> z.kari...@gmail.com >>>>>> 🌧️🌍🌱 >>>>>> >>>>>> >>>>>> On Tue, 23 Aug 2022, 05:16 Peter Stahlecker, <peter.st...@gmail.com> >>>>>> wrote: >>>>>> >>>>>>> Dear Zohreh, >>>>>>> >>>>>>> Just for my understanding: >>>>>>> 1. >>>>>>> You params are alpha, betta ,gamma, eta (?) >>>>>>> 2. >>>>>>> What do you mean by generating them dynamically? >>>>>>> >>>>>>> Peter >>>>>>> >>>>>>> On Tue 23. Aug 2022 at 02:44 Zohreh Karimzadeh <z.kari...@gmail.com> >>>>>>> wrote: >>>>>>> >>>>>>>> Dear Oscar >>>>>>>> BIG help ! >>>>>>>> Here I seriously need to use sympy to generate my params >>>>>>>> dynamically. >>>>>>>> All Bests >>>>>>>> Zohreh Karimzadeh >>>>>>>> *https://www.researchgate.net/profile/Zohreh-Karimzadeh* >>>>>>>> <https://www.researchgate.net/profile/Zohreh-Karimzadeh> >>>>>>>> Skype Name 49a52224a8b6b38b >>>>>>>> Twitter Account @zohrehkarimzad1 >>>>>>>> z.kari...@gmail.com >>>>>>>> +989102116325 <+98%20910%20211%206325> >>>>>>>> >>>>>>>> ((((((((((((((((Value Water))))))))))))))) >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Aug 22, 2022 at 7:42 PM Oscar Benjamin < >>>>>>>> oscar.j....@gmail.com> wrote: >>>>>>>> >>>>>>>>> On Mon, 22 Aug 2022 at 15:36, Peter Stahlecker >>>>>>>>> <peter.st...@gmail.com> wrote: >>>>>>>>> > >>>>>>>>> > Dear Oscar, >>>>>>>>> > >>>>>>>>> > Thanks for your hint about these parameters!. >>>>>>>>> > Probably dumb question of mine: >>>>>>>>> > Could one not define f_Vi_est directly as >>>>>>>>> > >>>>>>>>> > def_Vi_est(gamma, alfa, beta, eta, L, K, VA): >>>>>>>>> > Vi_est = gamma - (1 / eta)….. >>>>>>>>> > return np.sum(…..) >>>>>>>>> > >>>>>>>>> > without any ‚lambdification‘? >>>>>>>>> >>>>>>>>> Yes. In an earlier post the OP showed that they had working code >>>>>>>>> like >>>>>>>>> that but wanted to know how to do it using SymPy and lambdify. I >>>>>>>>> presume there is a reason for wanting to use SymPy there (perhaps >>>>>>>>> to >>>>>>>>> accomplish something slightly different from the exact code shown). >>>>>>>>> It's also possible that there isn't any actual reason to use SymPy >>>>>>>>> for >>>>>>>>> this at all though. >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Oscar >>>>>>>>> >>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "sympy" group. >>>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>>> send an email to sympy+un...@googlegroups.com. >>>>>>>>> To view this discussion on the web visit >>>>>>>>> https://groups.google.com/d/msgid/sympy/CAHVvXxQJUuZ4tVnECPyWE%3DLd03hhhUB5mqv1bjHcjSNf9WP22Q%40mail.gmail.com >>>>>>>>> . >>>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "sympy" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to sympy+un...@googlegroups.com. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/sympy/CA%2B1XYLOMV_i3VJXwwVN7JWnuJ9Wo6ZPhULmC1SOubAfFLt-DBQ%40mail.gmail.com >>>>>>>> <https://groups.google.com/d/msgid/sympy/CA%2B1XYLOMV_i3VJXwwVN7JWnuJ9Wo6ZPhULmC1SOubAfFLt-DBQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> >>>>>>> -- >>>>>>> Best regards, >>>>>>> >>>>>>> Peter Stahlecker >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "sympy" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to sympy+un...@googlegroups.com. >>>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/sympy/CABKqA0YTOzyZkjhnQmKQKQh-Mrc_H_TcmD9FrXObaTadkfLpkQ%40mail.gmail.com >>>>>>> <https://groups.google.com/d/msgid/sympy/CABKqA0YTOzyZkjhnQmKQKQh-Mrc_H_TcmD9FrXObaTadkfLpkQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> >>>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "sympy" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to sympy+un...@googlegroups.com. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/sympy/17d62c5c-11d8-4b1b-9a44-ae67c8021832n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/sympy/17d62c5c-11d8-4b1b-9a44-ae67c8021832n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>> >>> >>>> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sympy+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/837a3351-3aa3-4e1e-98d6-b34f3185d5b2n%40googlegroups.com >> <https://groups.google.com/d/msgid/sympy/837a3351-3aa3-4e1e-98d6-b34f3185d5b2n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sympy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CA%2B1XYLMEq2OLN0npw8RHfghS7m6vgewkrpshqw8gBBU%2BfUAnoQ%40mail.gmail.com > <https://groups.google.com/d/msgid/sympy/CA%2B1XYLMEq2OLN0npw8RHfghS7m6vgewkrpshqw8gBBU%2BfUAnoQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Best regards, Peter Stahlecker -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CABKqA0b261cO3ixRjsp_YPU0Yk1ahRVgnEytcOkLrQUW-eHdwQ%40mail.gmail.com.