You left out a lot of needed detail for a system design to be possible. But, I’ll make some assumptions and provide a solution.
I’ll assume your battery is a bank of Lithium Ions since you stated kWh instead of amp hours. LiFePo4 is a common battery used in these configurations and usually in 5kWh or 10kWh package sizes so I guess you are talking 8 or 4 batteries to get to 40kWh. These batteries usually have their own BMS (battery management system) built in but just have to have a source of voltage from a charge controller able to be configured for lithium batteries.
I’ll also assume the system voltage is nominally 48 volts. Lithiums are usually 51 volts but associated equipment normally is based on 48 volts.
Then finally I have no clue what Watt rating your 30 solar panels have so I’ll just take a wild guess that if you are using lithium batteries you are probably going to use tier 1 top quality panels. I’ll peg the panels at 400 Watts.
So: 30 panels at 400 Watts is 12,000 Watts. Your charge controller(s) must handle 12kW then. You can probably expect to get about 4 hours of noon equivalent sunshine per day so that means you can comfortably charge your batter bank with power to spare. 12kW X 4hr X .85 = 40.8kWh available and your battery is 40kWh.
I would probably use three 48 volt at 100 amp controllers with 10 solar panels connected to each controller. The number of panels tied together in each string would have to match the capacity of the controller you choose. This is critical so get help from the controller supplier to be sure your panel voltage won’t exceed the controller capacity and that the controller can be configured to charge lithium batteries. There are not a large number of choices on the market right now that will fit this system. Victron, Outback and Morning Star are three that come to mind, but there are others. I can’t over emphasize how important is that this part of the system be done correctly. A mistake could destroy $20,000 worth of batteries, but done correctly the system could last 15 to 20 years.